//
// AWS Manager - A free AWS console application demonstrating advanced concepts
// Copyright (C) 2008-2010 Sean O'Dell. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
/*
 * AWSMain.java
 *
 * Created on Jul 8, 2008, 10:14:53 PM
 */
package awsmanager;

import com.awsmanager.common.AWSCredential;
import com.awsmanager.common.EC2Instance;
import com.awsmanager.common.EC2Image;
import com.awsmanager.common.S3StorageBucket;
import com.awsmanager.common.EBSVolume;
import com.awsmanager.common.EBSSnapshot;
import com.awsmanager.common.EC2Connection;
import com.awsmanager.common.EC2IP;
import com.awsmanager.common.EC2KeyPair;
import com.awsmanager.common.EC2Region;
import com.awsmanager.common.EC2SecurityGroup;
import com.awsmanager.common.S3StorageConnection;
import com.awsmanager.common.S3StorageServer;
import com.awsmanager.common.SDBConnection;
import com.awsmanager.common.SDBItem;
import com.awsmanager.common.SDBServer;
import com.awsmanager.utils.ProcessText;
import com.sun.data.provider.FilterCriteria;
import com.sun.data.provider.RowKey;
import com.sun.data.provider.impl.CompareFilterCriteria;
import com.sun.data.provider.impl.RegexFilterCriteria;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Accordion;
import com.sun.webui.jsf.component.AddRemove;
import com.sun.webui.jsf.component.Checkbox;
import com.sun.webui.jsf.component.DropDown;
import com.sun.webui.jsf.component.PageAlert;
import com.sun.webui.jsf.component.PanelLayout;
import com.sun.webui.jsf.component.PasswordField;
import com.sun.webui.jsf.component.TabSet;
import com.sun.webui.jsf.component.Table;
import com.sun.webui.jsf.component.TableRowGroup;
import com.sun.webui.jsf.component.TextField;
import com.sun.webui.jsf.component.Upload;
import com.sun.webui.jsf.model.MultipleSelectOptionsList;
import com.sun.webui.jsf.model.Option;
import com.sun.webui.jsf.model.SingleSelectOptionsList;
import com.sun.webui.jsf.model.UploadedFile;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.FacesException;
import javax.faces.context.FacesContext;
import javax.faces.convert.IntegerConverter;
import javax.faces.convert.NumberConverter;
import javax.faces.event.ValueChangeEvent;
import javax.servlet.ServletContext;

/**
 * <p>Page bean that corresponds to a similarly named JSP page.  This
 * class contains component definitions (and initialization code) for
 * all components that you have defined on this page, as well as
 * lifecycle methods and event handlers where you may add behavior
 * to respond to incoming events.</p>
 *
 * @author Sean ODell
 */
public class AWSMain extends AbstractPageBean {
    // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">

    /**
     * <p>Automatically managed component initialization.  <strong>WARNING:</strong>
     * This method is automatically generated, so any user-specified code inserted
     * here is subject to being replaced.</p>
     */
    private void _init() throws Exception {
        ddl_VolStatusDefaultOptions.setOptions(new com.sun.webui.jsf.model.Option[]{new com.sun.webui.jsf.model.Option("", "Select Status"), new com.sun.webui.jsf.model.Option("available", "available"), new com.sun.webui.jsf.model.Option("in-use", "in-use"), new com.sun.webui.jsf.model.Option("creating", "creating"), new com.sun.webui.jsf.model.Option("deleting", "deleting")});
        ddl_ImageAvailabilityDefaultOptions.setOptions(new com.sun.webui.jsf.model.Option[]{new com.sun.webui.jsf.model.Option("", "Select Availability"), new com.sun.webui.jsf.model.Option("public", "public"), new com.sun.webui.jsf.model.Option("private", "private")});
        ddl_InstanceState1DefaultOptions.setOptions(new com.sun.webui.jsf.model.Option[]{new com.sun.webui.jsf.model.Option("", "Select State"), new com.sun.webui.jsf.model.Option("running", "running"), new com.sun.webui.jsf.model.Option("pending", "pending"), new com.sun.webui.jsf.model.Option("shutting-down", "shutting-down"), new com.sun.webui.jsf.model.Option("terminated", "terminated")});
        numberConverter1.setMinIntegerDigits(1);
        numberConverter1.setMaxIntegerDigits(40);
        numberConverter1.setIntegerOnly(true);
        ddl_SDBItemTypeDefaultOptions.setOptions(new com.sun.webui.jsf.model.Option[]{new com.sun.webui.jsf.model.Option("", "Select Type"), new com.sun.webui.jsf.model.Option("elasticip", "Elasitic IP"), new com.sun.webui.jsf.model.Option("instance", "Instance"), new com.sun.webui.jsf.model.Option("snapshot", "Snapshot"), new com.sun.webui.jsf.model.Option("volume", "Volume")});
        numberConverter1.setMaxFractionDigits(3);
    }
    //******************************************************************
    private TabSet tabSet_AWS_Main = new TabSet();

    public TabSet getTabSet_AWS_Main() {
        return tabSet_AWS_Main;
    }

    public void setTabSet_AWS_Main(TabSet ts) {
        this.tabSet_AWS_Main = ts;
    }
    //******************************************************************
    private TableRowGroup trg_EC2_Instances = new TableRowGroup();

    public TableRowGroup getTrg_EC2_Instances() {
        return trg_EC2_Instances;
    }

    public void setTrg_EC2_Instances(TableRowGroup trg) {
        this.trg_EC2_Instances = trg;
    }
    //******************************************************************
    private TableRowGroup trg_EC2_Images = new TableRowGroup();

    public TableRowGroup getTrg_EC2_Images() {
        return trg_EC2_Images;
    }

    public void setTrg_EC2_Images(TableRowGroup trg) {
        this.trg_EC2_Images = trg;
    }
    //******************************************************************
    private TableRowGroup trg_EBS_Volumes = new TableRowGroup();

    public TableRowGroup getTrg_EBS_Volumes() {
        return trg_EBS_Volumes;
    }

    public void setTrg_EBS_Volumes(TableRowGroup trg) {
        this.trg_EBS_Volumes = trg;
    }
    //******************************************************************
    private TableRowGroup trg_EBS_Snapshots = new TableRowGroup();

    public TableRowGroup getTrg_EBS_Snapshots() {
        return trg_EBS_Snapshots;
    }

    public void setTrg_EBS_Snapshots(TableRowGroup trg) {
        this.trg_EBS_Snapshots = trg;
    }
    //******************************************************************
    private String str_AWS_Secret_Access_Key = null;
    private Upload fu_AWS_Props = new Upload();

    public Upload getFu_AWS_Props() {
        return fu_AWS_Props;
    }

    public void setFu_AWS_Props(Upload u) {
        this.fu_AWS_Props = u;
    }
    private TextField tf_AWS_Access_Key = new TextField();

    public TextField getTf_AWS_Access_Key() {
        return tf_AWS_Access_Key;
    }

    public void setTf_AWS_Access_Key(TextField tf) {
        this.tf_AWS_Access_Key = tf;
    }
    private PasswordField tf_AWS_Secret_Access_Key = new PasswordField();

    public PasswordField getTf_AWS_Secret_Access_Key() {
        return tf_AWS_Secret_Access_Key;
    }

    public void setTf_AWS_Secret_Access_Key(PasswordField pf) {
        this.tf_AWS_Secret_Access_Key = pf;
    }
    private TextField tf_AWS_Account_ID = new TextField();

    public TextField getTf_AWS_Account_ID() {
        return tf_AWS_Account_ID;
    }

    public void setTf_AWS_Account_ID(TextField tf) {
        this.tf_AWS_Account_ID = tf;
    }
    private TextField tf_SSH_User = new TextField();

    public TextField getTf_SSH_User() {
        return tf_SSH_User;
    }

    public void setTf_SSH_User(TextField tf) {
        this.tf_SSH_User = tf;
    }
    private DropDown ddl_InstanceIds = new DropDown();

    public DropDown getDdl_InstanceIds() {
        return ddl_InstanceIds;
    }

    public void setDdl_InstanceIds(DropDown dd) {
        this.ddl_InstanceIds = dd;
    }
    private SingleSelectOptionsList ddl_VolStatusDefaultOptions = new SingleSelectOptionsList();

    public SingleSelectOptionsList getDdl_VolStatusDefaultOptions() {
        return ddl_VolStatusDefaultOptions;
    }

    public void setDdl_VolStatusDefaultOptions(SingleSelectOptionsList ssol) {
        this.ddl_VolStatusDefaultOptions = ssol;
    }
    private DropDown ddl_VolStatus = new DropDown();

    public DropDown getDdl_VolStatus() {
        return ddl_VolStatus;
    }

    public void setDdl_VolStatus(DropDown dd) {
        this.ddl_VolStatus = dd;
    }
    private Checkbox cb_MyImages = new Checkbox();

    public Checkbox getCb_MyImages() {
        return cb_MyImages;
    }

    public void setCb_MyImages(Checkbox c) {
        this.cb_MyImages = c;
    }
    private SingleSelectOptionsList ddl_ImageAvailabilityDefaultOptions = new SingleSelectOptionsList();

    public SingleSelectOptionsList getDdl_ImageAvailabilityDefaultOptions() {
        return ddl_ImageAvailabilityDefaultOptions;
    }

    public void setDdl_ImageAvailabilityDefaultOptions(SingleSelectOptionsList ssol) {
        this.ddl_ImageAvailabilityDefaultOptions = ssol;
    }
    private DropDown ddl_ImageAvailability = new DropDown();

    public DropDown getDdl_ImageAvailability() {
        return ddl_ImageAvailability;
    }

    public void setDdl_ImageAvailability(DropDown dd) {
        this.ddl_ImageAvailability = dd;
    }
    private Table table_EC2_Images = new Table();

    public Table getTable_EC2_Images() {
        return table_EC2_Images;
    }

    public void setTable_EC2_Images(Table t) {
        this.table_EC2_Images = t;
    }
    private Table table_EC2_Instances = new Table();

    public Table getTable_EC2_Instances() {
        return table_EC2_Instances;
    }

    public void setTable_EC2_Instances(Table t) {
        this.table_EC2_Instances = t;
    }
    private Table table_EBS_Volumes = new Table();

    public Table getTable_EBS_Volumes() {
        return table_EBS_Volumes;
    }

    public void setTable_EBS_Volumes(Table t) {
        this.table_EBS_Volumes = t;
    }
    private Table table_EBS_Snapshots = new Table();

    public Table getTable_EBS_Snapshots() {
        return table_EBS_Snapshots;
    }

    public void setTable_EBS_Snapshots(Table t) {
        this.table_EBS_Snapshots = t;
    }
    private SingleSelectOptionsList ddl_InstanceState1DefaultOptions = new SingleSelectOptionsList();

    public SingleSelectOptionsList getDdl_InstanceState1DefaultOptions() {
        return ddl_InstanceState1DefaultOptions;
    }

    public void setDdl_InstanceState1DefaultOptions(SingleSelectOptionsList ssol) {
        this.ddl_InstanceState1DefaultOptions = ssol;
    }
    private DropDown ddl_InstanceState = new DropDown();

    public DropDown getDdl_InstanceState1() {
        return ddl_InstanceState;
    }

    public void setDdl_InstanceState1(DropDown dd) {
        this.ddl_InstanceState = dd;
    }
    private DropDown ddl_InstanceImages = new DropDown();

    public DropDown getDdl_InstanceImages() {
        return ddl_InstanceImages;
    }

    public void setDdl_InstanceImages(DropDown dd) {
        this.ddl_InstanceImages = dd;
    }
    private DropDown ddl_InstanceAvailZone = new DropDown();

    public DropDown getDdl_AvailZoneInstances() {
        return ddl_InstanceAvailZone;
    }

    public void setDdl_AvailZoneInstances(DropDown dd) {
        this.ddl_InstanceAvailZone = dd;
    }
    private DropDown ddl_VolAvailZone = new DropDown();

    public DropDown getDdl_VolAvailZone() {
        return ddl_VolAvailZone;
    }

    public void setDdl_VolAvailZone(DropDown dd) {
        this.ddl_VolAvailZone = dd;
    }
    private Accordion ac_User = new Accordion();

    public Accordion getAc_User() {
        return ac_User;
    }

    public void setAc_User(Accordion a) {
        this.ac_User = a;
    }
    private Table table_S3Buckets = new Table();

    public Table getTable_S3Buckets() {
        return table_S3Buckets;
    }

    public void setTable_S3Buckets(Table t) {
        this.table_S3Buckets = t;
    }
    private TableRowGroup trg_S3Buckets = new TableRowGroup();

    public TableRowGroup getTrg_S3Buckets() {
        return trg_S3Buckets;
    }

    public void setTrg_S3Buckets(TableRowGroup trg) {
        this.trg_S3Buckets = trg;
    }
    private TextField tf_BucketNameFilter = new TextField();

    public TextField getTf_BucketNameFilter() {
        return tf_BucketNameFilter;
    }

    public void setTf_BucketNameFilter(TextField tf) {
        this.tf_BucketNameFilter = tf;
    }
    private PanelLayout lp_UserSettingsMsg = new PanelLayout();

    public PanelLayout getLp_UserSettingsMsg() {
        return lp_UserSettingsMsg;
    }

    public void setLp_UserSettingsMsg(PanelLayout pl) {
        this.lp_UserSettingsMsg = pl;
    }
    private NumberConverter numberConverter1 = new NumberConverter();

    public NumberConverter getNumberConverter1() {
        return numberConverter1;
    }

    public void setNumberConverter1(NumberConverter nc) {
        this.numberConverter1 = nc;
    }
    private TextField tf_SimpleDBDomainName = new TextField();

    public TextField getTf_SimpleDBDomainName() {
        return tf_SimpleDBDomainName;
    }

    public void setTf_SimpleDBDomainName(TextField tf) {
        this.tf_SimpleDBDomainName = tf;
    }
    private PanelLayout lp_EC2ConnectionMsg = new PanelLayout();

    public PanelLayout getLp_EC2ConnectionMsg() {
        return lp_EC2ConnectionMsg;
    }

    public void setLp_EC2ConnectionMsg(PanelLayout pl) {
        this.lp_EC2ConnectionMsg = pl;
    }
    private PanelLayout lp_SDBConnectionMsg = new PanelLayout();

    public PanelLayout getLp_SDBConnectionMsg() {
        return lp_SDBConnectionMsg;
    }

    public void setLp_SDBConnectionMsg(PanelLayout pl) {
        this.lp_SDBConnectionMsg = pl;
    }
    private Checkbox cb_EC2ReadAMIs = new Checkbox();

    public Checkbox getCb_EC2ReadAMIs() {
        return cb_EC2ReadAMIs;
    }

    public void setCb_EC2ReadAMIs(Checkbox c) {
        this.cb_EC2ReadAMIs = c;
    }
    private Table table_EC2_IPs = new Table();

    public Table getTable_EC2_IPs() {
        return table_EC2_IPs;
    }

    public void setTable_EC2_IPs(Table t) {
        this.table_EC2_IPs = t;
    }
    private TableRowGroup trg_EC2_IPs = new TableRowGroup();

    public TableRowGroup getTrg_EC2_IPs() {
        return trg_EC2_IPs;
    }

    public void setTrg_EC2_IPs(TableRowGroup trg) {
        this.trg_EC2_IPs = trg;
    }
    private Table table_EC2_Keypairs = new Table();

    public Table getTable_EC2_Keypairs() {
        return table_EC2_Keypairs;
    }

    public void setTable_EC2_Keypairs(Table t) {
        this.table_EC2_Keypairs = t;
    }
    private TableRowGroup trg_EC2_Keypairs = new TableRowGroup();

    public TableRowGroup getTrg_EC2_Keypairs() {
        return trg_EC2_Keypairs;
    }

    public void setTrg_EC2_Keypairs(TableRowGroup trg) {
        this.trg_EC2_Keypairs = trg;
    }
    private Table table_EC2_SecurityGroups = new Table();

    public Table getTable_EC2_SecurityGroups() {
        return table_EC2_SecurityGroups;
    }

    public void setTable_EC2_SecurityGroups(Table t) {
        this.table_EC2_SecurityGroups = t;
    }
    private TableRowGroup trg_EC2_SecurityGroups = new TableRowGroup();

    public TableRowGroup getTrg_EC2_SecurityGroups() {
        return trg_EC2_SecurityGroups;
    }

    public void setTrg_EC2_SecurityGroups(TableRowGroup trg) {
        this.trg_EC2_SecurityGroups = trg;
    }
    private Table table_SDB_Items = new Table();

    public Table getTable_SDB_Items() {
        return table_SDB_Items;
    }

    public void setTable_SDB_Items(Table t) {
        this.table_SDB_Items = t;
    }
    private TableRowGroup trg_SDB_Items = new TableRowGroup();

    public TableRowGroup getTrg_SDB_Items() {
        return trg_SDB_Items;
    }

    public void setTrg_SDB_Items(TableRowGroup trg) {
        this.trg_SDB_Items = trg;
    }
    private Checkbox cb_ActiveSDBItems = new Checkbox();

    public Checkbox getCb_ActiveSDBItems() {
        return cb_ActiveSDBItems;
    }

    public void setCb_ActiveSDBItems(Checkbox c) {
        this.cb_ActiveSDBItems = c;
    }
    private SingleSelectOptionsList ddl_SDBItemTypeDefaultOptions = new SingleSelectOptionsList();

    public SingleSelectOptionsList getDdl_SDBItemTypeDefaultOptions() {
        return ddl_SDBItemTypeDefaultOptions;
    }

    public void setDdl_SDBItemTypeDefaultOptions(SingleSelectOptionsList ssol) {
        this.ddl_SDBItemTypeDefaultOptions = ssol;
    }
    private DropDown ddl_SDBItemType = new DropDown();

    public DropDown getDdl_SDBItemType() {
        return ddl_SDBItemType;
    }

    public void setDdl_SDBItemType(DropDown dd) {
        this.ddl_SDBItemType = dd;
    }
    private MultipleSelectOptionsList checkboxGroup1DefaultOptions = new MultipleSelectOptionsList();

    public MultipleSelectOptionsList getCheckboxGroup1DefaultOptions() {
        return checkboxGroup1DefaultOptions;
    }

    public void setCheckboxGroup1DefaultOptions(MultipleSelectOptionsList msol) {
        this.checkboxGroup1DefaultOptions = msol;
    }
    private DropDown ddl_RegionAMIs = new DropDown();

    public DropDown getDdl_RegionAMIs() {
        return ddl_RegionAMIs;
    }

    public void setDdl_RegionAMIs(DropDown dd) {
        this.ddl_RegionAMIs = dd;
    }
    private DropDown ddl_RegionSnaps = new DropDown();

    public DropDown getDdl_RegionSnaps() {
        return ddl_RegionSnaps;
    }

    public void setDdl_RegionSnaps(DropDown dd) {
        this.ddl_RegionSnaps = dd;
    }
    private DropDown ddl_RegionKeypairs = new DropDown();

    public DropDown getDdl_RegionKeypairs() {
        return ddl_RegionKeypairs;
    }

    public void setDdl_RegionKeypairs(DropDown dd) {
        this.ddl_RegionKeypairs = dd;
    }
    private DropDown ddl_RegionSecurityGroups = new DropDown();

    public DropDown getDdl_RegionSecurityGroups() {
        return ddl_RegionSecurityGroups;
    }

    public void setDdl_RegionSecurityGroups(DropDown dd) {
        this.ddl_RegionSecurityGroups = dd;
    }
    private DropDown ddl_RegionEIPs = new DropDown();

    public DropDown getDdl_RegionEIPs() {
        return ddl_RegionEIPs;
    }

    public void setDdl_RegionEIPs(DropDown dd) {
        this.ddl_RegionEIPs = dd;
    }
    private DropDown ddl_AWSNickNames = new DropDown();

    public DropDown getDdl_AWSNickNames() {
        return ddl_AWSNickNames;
    }

    public void setDdl_AWSNickNames(DropDown dd) {
        this.ddl_AWSNickNames = dd;
    }
    private Checkbox cb_ConnectRegionUSE = new Checkbox();

    public Checkbox getCb_ConnectRegionUSE() {
        return cb_ConnectRegionUSE;
    }

    public void setCb_ConnectRegionUSE(Checkbox c) {
        this.cb_ConnectRegionUSE = c;
    }
    private AddRemove ari_Regions = new AddRemove();

    public AddRemove getAri_Regions() {
        return ari_Regions;
    }

    public void setAri_Regions(AddRemove ar) {
        this.ari_Regions = ar;
    }
    private DropDown ddl_AWS_S3Server = new DropDown();

    public DropDown getDdl_AWS_S3Server() {
        return ddl_AWS_S3Server;
    }

    public void setDdl_AWS_S3Server(DropDown dd) {
        this.ddl_AWS_S3Server = dd;
    }
    private Checkbox cb_MySnapshots = new Checkbox();

    public Checkbox getCb_MySnapshots() {
        return cb_MySnapshots;
    }

    public void setCb_MySnapshots(Checkbox c) {
        this.cb_MySnapshots = c;
    }
    private SingleSelectOptionsList dropDown1DefaultOptions = new SingleSelectOptionsList();

    public SingleSelectOptionsList getDropDown1DefaultOptions() {
        return dropDown1DefaultOptions;
    }

    public void setDropDown1DefaultOptions(SingleSelectOptionsList ssol) {
        this.dropDown1DefaultOptions = ssol;
    }
    private DropDown ddl_AWS_SDBServer = new DropDown();

    public DropDown getDdl_AWS_SDBServer() {
        return ddl_AWS_SDBServer;
    }

    public void setDdl_AWS_SDBServer(DropDown dd) {
        this.ddl_AWS_SDBServer = dd;
    }
    private IntegerConverter ic_ProxyPort = new IntegerConverter();

    public IntegerConverter getIc_ProxyPort() {
        return ic_ProxyPort;
    }

    public void setIc_ProxyPort(IntegerConverter ic) {
        this.ic_ProxyPort = ic;
    }

    //******************************************************************
    // </editor-fold>
    /**
     * <p>Construct a new Page bean instance.</p>
     */
    public AWSMain() {
    }

    /**
     * <p>Callback method that is called whenever a page is navigated to,
     * either directly via a URL, or indirectly via page navigation.
     * Customize this method to acquire resources that will be needed
     * for event handlers and lifecycle methods, whether or not this
     * page is performing post back processing.</p>
     *
     * <p>Note that, if the current request is a postback, the property
     * values of the components do <strong>not</strong> represent any
     * values submitted with this request.  Instead, they represent the
     * property values that were saved for this view when it was rendered.</p>
     */
    @Override
    public void init() {
        // Perform initializations inherited from our superclass
        super.init();
        // Perform application initialization that must complete
        // *before* managed components are initialized
        // TODO - add your own initialiation code here

        // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
        // Initialize automatically managed components
        // *Note* - this logic should NOT be modified
        try {
            _init();
        } catch (Exception e) {
            log("Page1 Initialization Failure", e);
            throw e instanceof FacesException ? (FacesException) e : new FacesException(e);
        }

        // </editor-fold>
        // Perform application initialization that must complete
        // *after* managed components are initialized
        // TODO - add your own initialization code here
        setInitTab("AWS_User_Settings");
        setAWSInitProps();
        restoreTableStates();
    }

    /**
     * <p>Callback method that is called after the component tree has been
     * restored, but before any event processing takes place.  This method
     * will <strong>only</strong> be called on a postback request that
     * is processing a form submit.  Customize this method to allocate
     * resources that will be required in your event handlers.</p>
     */
    @Override
    public void preprocess() {
    }

    /**
     * <p>Callback method that is called just before rendering takes place.
     * This method will <strong>only</strong> be called for the page that
     * will actually be rendered (and not, for example, on a page that
     * handled a postback and then navigated to a different page).  Customize
     * this method to allocate resources that will be required for rendering
     * this page.</p>
     */
    @Override
    public void prerender() {
    }

    /**
     * <p>Callback method that is called after rendering is completed for
     * this request, if <code>init()</code> was called (regardless of whether
     * or not this was the page that was actually rendered).  Customize this
     * method to release resources acquired in the <code>init()</code>,
     * <code>preprocess()</code>, or <code>prerender()</code> methods (or
     * acquired during execution of an event handler).</p>
     */
    @Override
    public void destroy() {
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected SessionBean1 getSessionBean1() {
        return (SessionBean1) getBean("SessionBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected RequestBean1 getRequestBean1() {
        return (RequestBean1) getBean("RequestBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected ApplicationBean1 getApplicationBean1() {
        return (ApplicationBean1) getBean("ApplicationBean1");
    }

    //-------------------------------------------------------------------------
    //User Settings tab is slected.
    public String AWS_User_Settings_action() {

        if ((str_AWS_Secret_Access_Key != null) && (!str_AWS_Secret_Access_Key.equals(""))) {
            lp_UserSettingsMsg.setRendered(true);
        } else {
            lp_UserSettingsMsg.setRendered(false);
        }

        setSDBFunctionsVisibleTables();
        checkEC2ConnectionStatusMsg();

        tabSet_AWS_Main.setSelected("AWS_User_Settings");
        getSessionBean1().setCurrentTabSet(tabSet_AWS_Main);

        return null;
    }

    public String EC2_Images_action() {
        getSessionBean1().clearSelected();
        tabSet_AWS_Main.setSelected("EC2_Images");
        getSessionBean1().setCurrentTabSet(tabSet_AWS_Main);
        return null;
    }

    public String EC2_Instances_action() {
        getSessionBean1().clearSelected();
        tabSet_AWS_Main.setSelected("EC2_Instances");
        getSessionBean1().setCurrentTabSet(tabSet_AWS_Main);
        getSessionBean1().setImageIDsOptions(
                getSessionBean1().ec2InstanceDataProvider.getImageIDsOptions());
        return null;
    }

    public String EBS_Volumes_action() {
        getSessionBean1().clearSelected();
        tabSet_AWS_Main.setSelected("EBS_Volumes");
        getSessionBean1().setCurrentTabSet(tabSet_AWS_Main);
        getSessionBean1().setInstanceIDsOptions(
                getSessionBean1().ec2InstanceDataProvider.getInstanceIDsOptions());
        return null;
    }

    public String EBS_Snapshots_action() {
        getSessionBean1().clearSelected();
        tabSet_AWS_Main.setSelected("EBS_Snapshots");
        getSessionBean1().setCurrentTabSet(tabSet_AWS_Main);
        return null;
    }

    public String EC2_Keypairs_action() {
        getSessionBean1().clearSelected();
        tabSet_AWS_Main.setSelected("EC2_Keypairs");
        getSessionBean1().setCurrentTabSet(tabSet_AWS_Main);
        return null;
    }

    public String EC2_SecurityGroups_action() {
        getSessionBean1().clearSelected();
        tabSet_AWS_Main.setSelected("EC2_SecurityGroups");
        getSessionBean1().setCurrentTabSet(tabSet_AWS_Main);
        return null;
    }

    public String EC2_IPs_action() {
        getSessionBean1().clearSelected();
        tabSet_AWS_Main.setSelected("EC2_IPs");
        getSessionBean1().setCurrentTabSet(tabSet_AWS_Main);
        getSessionBean1().setInstanceIDsOptions(
                getSessionBean1().ec2InstanceDataProvider.getInstanceIDsOptions());
        return null;
    }

    public String SDB_Items_action() {
        getSessionBean1().clearSelected();
        tabSet_AWS_Main.setSelected("SDB_Items");
        getSessionBean1().setCurrentTabSet(tabSet_AWS_Main);
        return null;
    }

    public String S3_Storage_action() {
        getSessionBean1().clearSelected();
        tabSet_AWS_Main.setSelected("S3_Storage");
        getSessionBean1().setCurrentTabSet(tabSet_AWS_Main);
        return null;
    }

    //-------------------------------------------------------------------------
    public String refreshView_Images_action() {
        try {
            getSessionBean1().getEC2ImageDataProvider().load(getSessionBean1().getEc2Connection(),
                    getSessionBean1().getAWSProps());
            getSessionBean1().setEc2AKIOptions(getSessionBean1().getEC2ImageDataProvider().getEc2AKIOptions());
            getSessionBean1().setEc2ARIOptions(getSessionBean1().getEC2ImageDataProvider().getEc2ARIOptions());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public String refreshView_Instances_action() {
        try {
            getSessionBean1().getEC2InstanceDataProvider().load(getSessionBean1().getEc2Connection(),
                    getSessionBean1().getSdbConnection());
            getSessionBean1().setImageIDsOptions(
                    getSessionBean1().ec2InstanceDataProvider.getImageIDsOptions());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public String refreshView_Volumes_action() {
        try {
            getSessionBean1().getEBSVolumeDataProvider().load(getSessionBean1().getEc2Connection(),
                    getSessionBean1().getSdbConnection());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public String refreshView_Snapshots_action() {
        try {
            getSessionBean1().getEBSSnapshotDataProvider().load(getSessionBean1().getEc2Connection(),
                    getSessionBean1().getSdbConnection());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public String refreshView_KeyPairs_action() {
        try {
            getSessionBean1().getEc2KeyPairDataProvider().load(getSessionBean1().getEc2Connection());
            getSessionBean1().setKeyPairNamesOptions(
                    getSessionBean1().getEc2KeyPairDataProvider().getKeyPairNamesOptions());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public String refreshView_SecurityGroups_action() {
        try {
            getSessionBean1().getEc2SecurityGroupDataProvider().load(getSessionBean1().getEc2Connection());
            getSessionBean1().setSecurityGroupsOptions(
                    getSessionBean1().getEc2SecurityGroupDataProvider().getSecurityGroupsOptions());

        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public String refreshView_EC2IPs_action() {
        try {
            getSessionBean1().getEc2IPDataProvider().load(getSessionBean1().getEc2Connection(),
                    getSessionBean1().getSdbConnection(),
                    getSessionBean1().getEC2InstanceDataProvider());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public String refreshView_EC2Regions_action() {
        try {
            getSessionBean1().getEc2RegionDataProvider().load(getSessionBean1().getEc2Connection());

            if (getSessionBean1().getEc2Connection() != null) {
                getSessionBean1().setEc2AvailabilityZoneOptions(
                        getSessionBean1().getEc2Connection().getZoneOptions());
                getSessionBean1().setEc2AvailabilityZoneOptionsFilter(
                        getSessionBean1().getEc2Connection().getZoneOptionsFilter());

                getSessionBean1().setEc2RegionOptions(
                        getSessionBean1().getEc2Connection().getRegionOptions());
                getSessionBean1().setEc2RegionOptionsFilter(
                        getSessionBean1().getEc2Connection().getRegionOptionsFilter());
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public String refreshView_SDBItems_action() {
        try {
            getSessionBean1().getSdbItemDataProvider().load(getSessionBean1().getSdbConnection(),
                    getSessionBean1().getDataproviders());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public String refreshView_S3Buckets_action() {
        try {
            S3StorageConnection s3StorageConnection = getSessionBean1().getS3StorageConnection();
            getSessionBean1().getS3StorageBucketDataProvider().load(getSessionBean1().getAWSProps(), s3StorageConnection);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    //-------------------------------------------------------------------------
    public String flterTable_Images_action() {

        boolean filterFlag = false;
        boolean regExFilterFlag = false;

        CompareFilterCriteria compareFilterCriteria = new CompareFilterCriteria();
        RegexFilterCriteria regexFilterCriteria = new RegexFilterCriteria();

        ArrayList filterList = new ArrayList();
        ArrayList regExfilterList = new ArrayList();

        Properties awsProps = getSessionBean1().getAWSProps();

        getTrg_EC2_Images().clearFilter();

        if (cb_MyImages != null) {
            if (cb_MyImages.isChecked()) {
                String accountId = awsProps.getProperty("aws.accountId");
                if (!accountId.equals("")) {
                    filterFlag = true;
                    compareFilterCriteria = new CompareFilterCriteria(getSessionBean1().getEC2ImageDataProvider().getFieldKey("imageOwnerId"), accountId);
                    filterList.add(compareFilterCriteria);
                }
            }
        }

        if (ddl_ImageAvailability.getSelected() != null) {
            String selectedImageAvailability = ddl_ImageAvailability.getSelected().toString();
            if (!selectedImageAvailability.equals("")) {
                filterFlag = true;
                compareFilterCriteria = new CompareFilterCriteria(getSessionBean1().getEC2ImageDataProvider().getFieldKey("isPublic"), selectedImageAvailability);
                filterList.add(compareFilterCriteria);
            }
        }

        if (ddl_RegionAMIs.getSelected() != null) {
            String selectedRegion = ddl_RegionAMIs.getSelected().toString();
            if (!selectedRegion.equals("")) {
                filterFlag = true;
                compareFilterCriteria = new CompareFilterCriteria(getSessionBean1().getEC2ImageDataProvider().getFieldKey("imageRegion"), selectedRegion);
                filterList.add(compareFilterCriteria);
            }
        }

        Map tableFiltersFields = getSessionBean1().getTableFiltersFields();
        String selectedImageLocation = null;
        String selectedImageOwner = null;

        if ((selectedImageLocation = (String) tableFiltersFields.get("imageLocationFilter")) != null) {
            if (!selectedImageLocation.equals("")) {
                selectedImageLocation = selectedImageLocation.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEC2ImageDataProvider().getFieldKey("imageLocation"), ".*" + selectedImageLocation + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedImageOwner = (String) tableFiltersFields.get("imageLocationOwner")) != null) {
            if (!selectedImageOwner.equals("")) {
                selectedImageOwner = selectedImageOwner.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEC2ImageDataProvider().getFieldKey("imageOwnerId"), ".*" + selectedImageOwner + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if (filterFlag || regExFilterFlag) {
            int fsize = filterList.size();
            int regExfsize = regExfilterList.size();
            FilterCriteria filterCriteria[] = new FilterCriteria[fsize + regExfsize];
            if (filterFlag) {
                for (int i = 0; i < fsize; i++) {
                    filterCriteria[i] = (CompareFilterCriteria) filterList.get(i);
                }
            }
            if (regExFilterFlag) {
                for (int i = 0; i < regExfsize; i++) {
                    filterCriteria[i + fsize] = (RegexFilterCriteria) regExfilterList.get(i);
                }
            }
            getTrg_EC2_Images().getTableDataFilter().setFilterCriteria(filterCriteria);
        }
        return null;
    }

    public String flterTable_Images_reset() {
        cb_MyImages.setValue((Boolean) false);
        ddl_ImageAvailability.setSelected(null);
        ddl_RegionAMIs.setSelected(null);
        getTrg_EC2_Images().clearFilter();
        return null;
    }
    //-------------------------------------------------------------------------

    public String flterTable_Instances_action() {

        boolean filterFlag = false;
        boolean regExFilterFlag = false;

        CompareFilterCriteria compareFilterCriteria = new CompareFilterCriteria();
        RegexFilterCriteria regexFilterCriteria = new RegexFilterCriteria();

        ArrayList filterList = new ArrayList();
        ArrayList regExfilterList = new ArrayList();

        getTrg_EC2_Instances().clearFilter();

        if (ddl_InstanceAvailZone.getSelected() != null) {
            String selectedInstanceZone = ddl_InstanceAvailZone.getSelected().toString();
            if (!selectedInstanceZone.equals("")) {
                filterFlag = true;
                compareFilterCriteria = new CompareFilterCriteria(getSessionBean1().getEC2InstanceDataProvider().getFieldKey("availabilityZone"), selectedInstanceZone);
                filterList.add(compareFilterCriteria);
            }
        }

        if (ddl_InstanceState.getSelected() != null) {
            String selectedInstanceState = ddl_InstanceState.getSelected().toString();
            if (!selectedInstanceState.equals("")) {
                filterFlag = true;
                compareFilterCriteria = new CompareFilterCriteria(getSessionBean1().getEC2InstanceDataProvider().getFieldKey("stateName"), selectedInstanceState);
                filterList.add(compareFilterCriteria);
            }
        }

        if (ddl_InstanceImages.getSelected() != null) {
            String selectedInstanceImages = ddl_InstanceImages.getSelected().toString();
            if (!selectedInstanceImages.equals("")) {
                filterFlag = true;
                compareFilterCriteria = new CompareFilterCriteria(getSessionBean1().getEC2InstanceDataProvider().getFieldKey("imageId"), selectedInstanceImages);
                filterList.add(compareFilterCriteria);
            }
        }

        Map tableFiltersFields = getSessionBean1().getTableFiltersFields();
        String selectedInstanceName = null;
        String selectedInstanceDesc = null;
        String selectedOwnerLast = null;
        String selectedOwnerFirst = null;
        String selectedOwnerDept = null;
        String selectedType = null;
        String selectedPublicIP = null;
        String selectedPrivateIP = null;

        if ((selectedInstanceName = (String) tableFiltersFields.get("instInstanceName")) != null) {
            if (!selectedInstanceName.equals("")) {
                selectedInstanceName = selectedInstanceName.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEC2InstanceDataProvider().getFieldKey("instname"), ".*" + selectedInstanceName + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedInstanceDesc = (String) tableFiltersFields.get("instInstanceDesc")) != null) {
            if (!selectedInstanceDesc.equals("")) {
                selectedInstanceDesc = selectedInstanceDesc.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEC2InstanceDataProvider().getFieldKey("instdesc"), ".*" + selectedInstanceDesc + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedOwnerLast = (String) tableFiltersFields.get("instOwnerLast")) != null) {
            if (!selectedOwnerLast.equals("")) {
                selectedOwnerLast = selectedOwnerLast.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEC2InstanceDataProvider().getFieldKey("instownernamelast"), ".*" + selectedOwnerLast + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedOwnerFirst = (String) tableFiltersFields.get("instOwnerFirst")) != null) {
            if (!selectedOwnerFirst.equals("")) {
                selectedOwnerFirst = selectedOwnerFirst.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEC2InstanceDataProvider().getFieldKey("instownernamefirst"), ".*" + selectedOwnerFirst + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedOwnerDept = (String) tableFiltersFields.get("instOwnerDept")) != null) {
            if (!selectedOwnerDept.equals("")) {
                selectedOwnerDept = selectedOwnerDept.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEC2InstanceDataProvider().getFieldKey("instownerdept"), ".*" + selectedOwnerDept + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedType = (String) tableFiltersFields.get("instType")) != null) {
            if (!selectedType.equals("")) {
                selectedType = selectedType.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEC2InstanceDataProvider().getFieldKey("instanceType"), ".*" + selectedType + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedPublicIP = (String) tableFiltersFields.get("instPublicIP")) != null) {
            if (!selectedPublicIP.equals("")) {
                selectedPublicIP = selectedPublicIP.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEC2InstanceDataProvider().getFieldKey("dnsName"), ".*" + selectedPublicIP + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedPrivateIP = (String) tableFiltersFields.get("instPrivateIP")) != null) {
            if (!selectedPrivateIP.equals("")) {
                selectedPrivateIP = selectedPrivateIP.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEC2InstanceDataProvider().getFieldKey("privateDnsName"), ".*" + selectedPrivateIP + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if (filterFlag || regExFilterFlag) {
            int fsize = filterList.size();
            int regExfsize = regExfilterList.size();
            FilterCriteria filterCriteria[] = new FilterCriteria[fsize + regExfsize];
            if (filterFlag) {
                for (int i = 0; i < fsize; i++) {
                    filterCriteria[i] = (CompareFilterCriteria) filterList.get(i);
                }
            }
            if (regExFilterFlag) {
                for (int i = 0; i < regExfsize; i++) {
                    filterCriteria[i + fsize] = (RegexFilterCriteria) regExfilterList.get(i);
                }
            }
            getTrg_EC2_Instances().getTableDataFilter().setFilterCriteria(filterCriteria);
        }

        return null;
    }

    public String flterTable_Instances_reset() {
        ddl_InstanceAvailZone.setSelected(null);
        ddl_InstanceState.setSelected(null);
        ddl_InstanceImages.setSelected(null);
        getTrg_EC2_Instances().clearFilter();
        return null;
    }
    //-------------------------------------------------------------------------

    public String flterTable_Volumes_action() {

        boolean filterFlag = false;
        boolean regExFilterFlag = false;

        CompareFilterCriteria compareFilterCriteria = new CompareFilterCriteria();
        RegexFilterCriteria regexFilterCriteria = new RegexFilterCriteria();

        ArrayList filterList = new ArrayList();
        ArrayList regExfilterList = new ArrayList();

        getTrg_EBS_Volumes().clearFilter();

        if (ddl_VolAvailZone.getSelected() != null) {
            String selectedVolZone = ddl_VolAvailZone.getSelected().toString();
            if (!selectedVolZone.equals("")) {
                filterFlag = true;
                compareFilterCriteria = new CompareFilterCriteria(getSessionBean1().getEBSVolumeDataProvider().getFieldKey("zone"), selectedVolZone);
                filterList.add(compareFilterCriteria);
            }
        }

        if (ddl_InstanceIds.getSelected() != null) {
            String selectedInstanceID = ddl_InstanceIds.getSelected().toString();
            if (!selectedInstanceID.equals("")) {
                filterFlag = true;
                compareFilterCriteria = new CompareFilterCriteria(getSessionBean1().getEBSVolumeDataProvider().getFieldKey("instanceId"), selectedInstanceID);
                filterList.add(compareFilterCriteria);
            }
        }

        if (ddl_VolStatus.getSelected() != null) {
            String selectedVolStatus = ddl_VolStatus.getSelected().toString();
            if (!selectedVolStatus.equals("")) {
                filterFlag = true;
                compareFilterCriteria = new CompareFilterCriteria(getSessionBean1().getEBSVolumeDataProvider().getFieldKey("vstatus"), selectedVolStatus);
                filterList.add(compareFilterCriteria);
            }
        }

        Map tableFiltersFields = getSessionBean1().getTableFiltersFields();
        String selectedVolName = null;
        String selectedVolDesc = null;
        String selectedSnapName = null;
        String selectedInstName = null;
        String selectedOwnerLast = null;
        String selectedOwnerFirst = null;
        String selectedOwnerDept = null;

        if ((selectedVolName = (String) tableFiltersFields.get("volVolumeName")) != null) {
            if (!selectedVolName.equals("")) {
                selectedVolName = selectedVolName.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEBSVolumeDataProvider().getFieldKey("volname"), ".*" + selectedVolName + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedVolDesc = (String) tableFiltersFields.get("volVolumeDesc")) != null) {
            if (!selectedVolDesc.equals("")) {
                selectedVolDesc = selectedVolDesc.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEBSVolumeDataProvider().getFieldKey("voldesc"), ".*" + selectedVolDesc + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedSnapName = (String) tableFiltersFields.get("volSnapshotName")) != null) {
            if (!selectedSnapName.equals("")) {
                selectedSnapName = selectedSnapName.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEBSVolumeDataProvider().getFieldKey("snapname"), ".*" + selectedSnapName + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedInstName = (String) tableFiltersFields.get("volInstanceName")) != null) {
            if (!selectedInstName.equals("")) {
                selectedInstName = selectedInstName.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEBSVolumeDataProvider().getFieldKey("instname"), ".*" + selectedInstName + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedOwnerLast = (String) tableFiltersFields.get("volOwnerLast")) != null) {
            if (!selectedOwnerLast.equals("")) {
                selectedOwnerLast = selectedOwnerLast.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEBSVolumeDataProvider().getFieldKey("volownernamelast"), ".*" + selectedOwnerLast + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedOwnerFirst = (String) tableFiltersFields.get("volOwnerFirst")) != null) {
            if (!selectedOwnerFirst.equals("")) {
                selectedOwnerFirst = selectedOwnerFirst.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEBSVolumeDataProvider().getFieldKey("volownernamefirst"), ".*" + selectedOwnerFirst + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedOwnerDept = (String) tableFiltersFields.get("volOwnerDept")) != null) {
            if (!selectedOwnerDept.equals("")) {
                selectedOwnerDept = selectedOwnerDept.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEBSVolumeDataProvider().getFieldKey("volownerdept"), ".*" + selectedOwnerDept + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if (filterFlag || regExFilterFlag) {
            int fsize = filterList.size();
            int regExfsize = regExfilterList.size();
            FilterCriteria filterCriteria[] = new FilterCriteria[fsize + regExfsize];
            if (filterFlag) {
                for (int i = 0; i < fsize; i++) {
                    filterCriteria[i] = (CompareFilterCriteria) filterList.get(i);
                }
            }
            if (regExFilterFlag) {
                for (int i = 0; i < regExfsize; i++) {
                    filterCriteria[i + fsize] = (RegexFilterCriteria) regExfilterList.get(i);
                }
            }
            getTrg_EBS_Volumes().getTableDataFilter().setFilterCriteria(filterCriteria);
        }

        return null;
    }

    public String flterTable_Volumes_reset() {
        ddl_VolAvailZone.setSelected(null);
        ddl_InstanceIds.setSelected(null);
        ddl_VolStatus.setSelected(null);
        getTrg_EBS_Volumes().clearFilter();
        return null;
    }
    //-------------------------------------------------------------------------

    public String flterTable_Snapshots_action() {

        boolean filterFlag = false;
        boolean regExFilterFlag = false;

        CompareFilterCriteria compareFilterCriteria = new CompareFilterCriteria();
        RegexFilterCriteria regexFilterCriteria = new RegexFilterCriteria();

        ArrayList filterList = new ArrayList();
        ArrayList regExfilterList = new ArrayList();

        getTrg_EBS_Snapshots().clearFilter();
        Properties awsProps = getSessionBean1().getAWSProps();

        Map tableFiltersFields = getSessionBean1().getTableFiltersFields();
        String selectedSnapName = null;
        String selectedSnapDesc = null;
        String selectedOwnerLast = null;
        String selectedOwnerFirst = null;
        String selectedOwnerDept = null;
        String selectedVolName = null;

        if (cb_MySnapshots != null) {
            if (cb_MySnapshots.isChecked()) {
                String accountId = awsProps.getProperty("aws.accountId");
                if (!accountId.equals("")) {
                    filterFlag = true;
                    compareFilterCriteria = new CompareFilterCriteria(getSessionBean1().getEBSSnapshotDataProvider().getFieldKey("ownerID"), accountId);
                    filterList.add(compareFilterCriteria);
                }
            }
        }

        if (ddl_RegionSnaps.getSelected() != null) {
            String selectedRegion = ddl_RegionSnaps.getSelected().toString();
            if (!selectedRegion.equals("")) {
                filterFlag = true;
                compareFilterCriteria = new CompareFilterCriteria(getSessionBean1().getEBSSnapshotDataProvider().getFieldKey("snapRegion"), selectedRegion);
                filterList.add(compareFilterCriteria);
            }
        }

        if ((selectedSnapName = (String) tableFiltersFields.get("snapSnapName")) != null) {
            if (!selectedSnapName.equals("")) {
                selectedSnapName = selectedSnapName.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEBSSnapshotDataProvider().getFieldKey("snapname"), ".*" + selectedSnapName + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedSnapDesc = (String) tableFiltersFields.get("snapSnapDesc")) != null) {
            if (!selectedSnapDesc.equals("")) {
                selectedSnapDesc = selectedSnapDesc.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEBSSnapshotDataProvider().getFieldKey("snapdesc"), ".*" + selectedSnapDesc + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedOwnerLast = (String) tableFiltersFields.get("snapOwnerLast")) != null) {
            if (!selectedOwnerLast.equals("")) {
                selectedOwnerLast = selectedOwnerLast.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEBSSnapshotDataProvider().getFieldKey("snapownernamelast"), ".*" + selectedOwnerLast + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedOwnerFirst = (String) tableFiltersFields.get("snapOwnerFirst")) != null) {
            if (!selectedOwnerFirst.equals("")) {
                selectedOwnerFirst = selectedOwnerFirst.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEBSSnapshotDataProvider().getFieldKey("snapownernamefirst"), ".*" + selectedOwnerFirst + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedOwnerDept = (String) tableFiltersFields.get("snapOwnerDept")) != null) {
            if (!selectedOwnerDept.equals("")) {
                selectedOwnerDept = selectedOwnerDept.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEBSSnapshotDataProvider().getFieldKey("snapownerdept"), ".*" + selectedOwnerDept + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedVolName = (String) tableFiltersFields.get("snapVolName")) != null) {
            if (!selectedVolName.equals("")) {
                selectedVolName = selectedVolName.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getEBSSnapshotDataProvider().getFieldKey("volname"), ".*" + selectedVolName + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if (filterFlag || regExFilterFlag) {
            int fsize = filterList.size();
            int regExfsize = regExfilterList.size();
            FilterCriteria filterCriteria[] = new FilterCriteria[fsize + regExfsize];
            if (filterFlag) {
                for (int i = 0; i < fsize; i++) {
                    filterCriteria[i] = (CompareFilterCriteria) filterList.get(i);
                }
            }
            if (regExFilterFlag) {
                for (int i = 0; i < regExfsize; i++) {
                    filterCriteria[i + fsize] = (RegexFilterCriteria) regExfilterList.get(i);
                }
            }
            getTrg_EBS_Snapshots().getTableDataFilter().setFilterCriteria(filterCriteria);
        }

        return null;
    }

    public String flterTable_Snapshots_reset() {
        cb_MySnapshots.setValue((Boolean) false);
        getTrg_EBS_Snapshots().clearFilter();
        ddl_RegionSnaps.setSelected(null);
        return null;
    }
    //-------------------------------------------------------------------------

    public String flterTable_Keypairs_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        boolean filterFlag = false;
        boolean regExFilterFlag = false;

        CompareFilterCriteria compareFilterCriteria = new CompareFilterCriteria();
        RegexFilterCriteria regexFilterCriteria = new RegexFilterCriteria();

        ArrayList filterList = new ArrayList();
        ArrayList regExfilterList = new ArrayList();

        getTrg_EC2_Keypairs().clearFilter();

        if (ddl_RegionKeypairs.getSelected() != null) {
            String selectedRegion = ddl_RegionKeypairs.getSelected().toString();
            if (!selectedRegion.equals("")) {
                filterFlag = true;
                compareFilterCriteria = new CompareFilterCriteria(getSessionBean1().getEc2KeyPairDataProvider().getFieldKey("keyRegion"), selectedRegion);
                filterList.add(compareFilterCriteria);
            }
        }

        if (filterFlag || regExFilterFlag) {
            int fsize = filterList.size();
            int regExfsize = regExfilterList.size();
            FilterCriteria filterCriteria[] = new FilterCriteria[fsize + regExfsize];
            if (filterFlag) {
                for (int i = 0; i < fsize; i++) {
                    filterCriteria[i] = (CompareFilterCriteria) filterList.get(i);
                }
            }
            if (regExFilterFlag) {
                for (int i = 0; i < regExfsize; i++) {
                    filterCriteria[i + fsize] = (RegexFilterCriteria) regExfilterList.get(i);
                }
            }
            getTrg_EC2_Keypairs().getTableDataFilter().setFilterCriteria(filterCriteria);
        }

        return null;
    }

    public String flterTable_Keypairs_reset() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        getTrg_EC2_Keypairs().clearFilter();
        ddl_RegionKeypairs.setSelected(null);
        return null;
    }
    //-------------------------------------------------------------------------

    public String flterTable_SecurityGroups_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        boolean filterFlag = false;
        boolean regExFilterFlag = false;

        CompareFilterCriteria compareFilterCriteria = new CompareFilterCriteria();
        RegexFilterCriteria regexFilterCriteria = new RegexFilterCriteria();

        ArrayList filterList = new ArrayList();
        ArrayList regExfilterList = new ArrayList();

        getTrg_EC2_SecurityGroups().clearFilter();

        if (ddl_RegionSecurityGroups.getSelected() != null) {
            String selectedRegion = ddl_RegionSecurityGroups.getSelected().toString();
            if (!selectedRegion.equals("")) {
                filterFlag = true;
                compareFilterCriteria = new CompareFilterCriteria(getSessionBean1().getEc2SecurityGroupDataProvider().getFieldKey("region"), selectedRegion);
                filterList.add(compareFilterCriteria);
            }
        }

        if (filterFlag || regExFilterFlag) {
            int fsize = filterList.size();
            int regExfsize = regExfilterList.size();
            FilterCriteria filterCriteria[] = new FilterCriteria[fsize + regExfsize];
            if (filterFlag) {
                for (int i = 0; i < fsize; i++) {
                    filterCriteria[i] = (CompareFilterCriteria) filterList.get(i);
                }
            }
            if (regExFilterFlag) {
                for (int i = 0; i < regExfsize; i++) {
                    filterCriteria[i + fsize] = (RegexFilterCriteria) regExfilterList.get(i);
                }
            }
            getTrg_EC2_SecurityGroups().getTableDataFilter().setFilterCriteria(filterCriteria);
        }

        return null;
    }

    public String flterTable_SecurityGroups_reset() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        getTrg_EC2_SecurityGroups().clearFilter();
        ddl_RegionSecurityGroups.setSelected(null);
        return null;
    }
    //-------------------------------------------------------------------------

    public String flterTable_EIPs_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        boolean filterFlag = false;
        boolean regExFilterFlag = false;

        CompareFilterCriteria compareFilterCriteria = new CompareFilterCriteria();
        RegexFilterCriteria regexFilterCriteria = new RegexFilterCriteria();

        ArrayList filterList = new ArrayList();
        ArrayList regExfilterList = new ArrayList();

        getTrg_EC2_IPs().clearFilter();

        if (ddl_RegionEIPs.getSelected() != null) {
            String selectedRegion = ddl_RegionEIPs.getSelected().toString();
            if (!selectedRegion.equals("")) {
                filterFlag = true;
                compareFilterCriteria = new CompareFilterCriteria(getSessionBean1().getEc2IPDataProvider().getFieldKey("region"), selectedRegion);
                filterList.add(compareFilterCriteria);
            }
        }

        if (filterFlag || regExFilterFlag) {
            int fsize = filterList.size();
            int regExfsize = regExfilterList.size();
            FilterCriteria filterCriteria[] = new FilterCriteria[fsize + regExfsize];
            if (filterFlag) {
                for (int i = 0; i < fsize; i++) {
                    filterCriteria[i] = (CompareFilterCriteria) filterList.get(i);
                }
            }
            if (regExFilterFlag) {
                for (int i = 0; i < regExfsize; i++) {
                    filterCriteria[i + fsize] = (RegexFilterCriteria) regExfilterList.get(i);
                }
            }
            getTrg_EC2_IPs().getTableDataFilter().setFilterCriteria(filterCriteria);
        }

        return null;
    }

    public String flterTable_EIPs_reset() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        getTrg_EC2_IPs().clearFilter();
        ddl_RegionEIPs.setSelected(null);
        return null;
    }
    //-------------------------------------------------------------------------

    public String flterTable_SDBItems_action() {

        boolean filterFlag = false;
        boolean regExFilterFlag = false;

        CompareFilterCriteria compareFilterCriteria = new CompareFilterCriteria();
        RegexFilterCriteria regexFilterCriteria = new RegexFilterCriteria();

        ArrayList filterList = new ArrayList();
        ArrayList regExfilterList = new ArrayList();

        getTrg_SDB_Items().clearFilter();

        if (cb_ActiveSDBItems != null) {
            if (cb_ActiveSDBItems.isChecked()) {
                filterFlag = true;
                compareFilterCriteria = new CompareFilterCriteria(getSessionBean1().getSdbItemDataProvider().getFieldKey("active"), true);
                filterList.add(compareFilterCriteria);
            }
        }

        if (ddl_SDBItemType.getSelected() != null) {
            String selectedSDBItemType = ddl_SDBItemType.getSelected().toString();
            if (!selectedSDBItemType.equals("")) {
                filterFlag = true;
                compareFilterCriteria = new CompareFilterCriteria(getSessionBean1().getSdbItemDataProvider().getFieldKey("type"), selectedSDBItemType);
                filterList.add(compareFilterCriteria);
            }
        }

        Map tableFiltersFields = getSessionBean1().getTableFiltersFields();
        String selectedItemName = null;
        String selectedItemDesc = null;
        String selectedOwnerLast = null;
        String selectedOwnerFirst = null;
        String selectedOwnerDept = null;

        if ((selectedItemName = (String) tableFiltersFields.get("sdbItemName")) != null) {
            if (!selectedItemName.equals("")) {
                selectedItemName = selectedItemName.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getSdbItemDataProvider().getFieldKey("name"), ".*" + selectedItemName + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedItemDesc = (String) tableFiltersFields.get("sdbItemDesc")) != null) {
            if (!selectedItemDesc.equals("")) {
                selectedItemDesc = selectedItemDesc.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getSdbItemDataProvider().getFieldKey("description"), ".*" + selectedItemDesc + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedOwnerLast = (String) tableFiltersFields.get("sdbOwnerLast")) != null) {
            if (!selectedOwnerLast.equals("")) {
                selectedOwnerLast = selectedOwnerLast.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getSdbItemDataProvider().getFieldKey("ownernamelast"), ".*" + selectedOwnerLast + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedOwnerFirst = (String) tableFiltersFields.get("sdbOwnerFirst")) != null) {
            if (!selectedOwnerFirst.equals("")) {
                selectedOwnerFirst = selectedOwnerFirst.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getSdbItemDataProvider().getFieldKey("ownernamefirst"), ".*" + selectedOwnerFirst + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if ((selectedOwnerDept = (String) tableFiltersFields.get("sdbOwnerDept")) != null) {
            if (!selectedOwnerDept.equals("")) {
                selectedOwnerDept = selectedOwnerDept.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getSdbItemDataProvider().getFieldKey("ownerdept"), ".*" + selectedOwnerDept + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }


        if (filterFlag || regExFilterFlag) {
            int fsize = filterList.size();
            int regExfsize = regExfilterList.size();
            FilterCriteria filterCriteria[] = new FilterCriteria[fsize + regExfsize];
            if (filterFlag) {
                for (int i = 0; i < fsize; i++) {
                    filterCriteria[i] = (CompareFilterCriteria) filterList.get(i);
                }
            }
            if (regExFilterFlag) {
                for (int i = 0; i < regExfsize; i++) {
                    filterCriteria[i + fsize] = (RegexFilterCriteria) regExfilterList.get(i);
                }
            }
            getTrg_SDB_Items().getTableDataFilter().setFilterCriteria(filterCriteria);
        }
        return null;
    }

    public String flterTable_SDBItems_reset() {
        cb_ActiveSDBItems.setValue((Boolean) false);
        ddl_SDBItemType.setSelected(null);
        getTrg_SDB_Items().clearFilter();
        return null;
    }
    //-------------------------------------------------------------------------

    public String flterTable_S3Buckets_action() {

        boolean filterFlag = false;
        boolean regExFilterFlag = false;
        RegexFilterCriteria regexFilterCriteria = new RegexFilterCriteria();

        ArrayList filterList = new ArrayList();
        ArrayList regExfilterList = new ArrayList();

        getTrg_S3Buckets().clearFilter();

        if (tf_BucketNameFilter.getText() != null) {
            String selectedBucketName = tf_BucketNameFilter.getText().toString();
            if (!selectedBucketName.equals("")) {
                selectedBucketName = selectedBucketName.replace("*", ".*");
                regExFilterFlag = true;
                regexFilterCriteria = new RegexFilterCriteria(getSessionBean1().getS3StorageBucketDataProvider().getFieldKey("name"), ".*" + selectedBucketName + ".*");
                regExfilterList.add(regexFilterCriteria);
            }
        }

        if (filterFlag || regExFilterFlag) {
            int fsize = filterList.size();
            int regExfsize = regExfilterList.size();
            FilterCriteria filterCriteria[] = new FilterCriteria[fsize + regExfsize];
            if (filterFlag) {
                for (int i = 0; i < fsize; i++) {
                    filterCriteria[i] = (CompareFilterCriteria) filterList.get(i);
                }
            }
            if (regExFilterFlag) {
                for (int i = 0; i < regExfsize; i++) {
                    filterCriteria[i + fsize] = (RegexFilterCriteria) regExfilterList.get(i);
                }
            }
            getTrg_S3Buckets().getTableDataFilter().setFilterCriteria(filterCriteria);
        }
        return null;
    }

    public String flterTable_S3Buckets_reset() {
        tf_BucketNameFilter.setText(null);
        getTrg_S3Buckets().clearFilter();
        return null;
    }

    //-------------------------------------------------------------------------
    public String launchInstances_action() {

        Map launchInstanceInfo = new HashMap();
        ArrayList launchInstanceList = new ArrayList();
        PageAlert questionAlert = new PageAlert();
        String detailMessage = new String();
        saveTableStates();

        int selectedRows = getTrg_EC2_Images().getSelectedRowsCount();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No Image is selected.");
            detailMessage = detailMessage + "Please select at least one image to launch an instance.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            return "infoAndReturn";
        }

        RowKey[] selectedRowKeys = getTrg_EC2_Images().getSelectedRowKeys();

        for (int i = 0; i < selectedRowKeys.length; i++) {
            String rowId = selectedRowKeys[i].getRowId();
            RowKey rowKey = getSessionBean1().getEC2ImageDataProvider().getRowKey(rowId);
            launchInstanceList.add(rowKey);
        }

        getSessionBean1().setInstanceIDsOptions(
                getSessionBean1().ec2InstanceDataProvider.getInstanceIDsOptions());

        launchInstanceInfo.put("instRowKeys", launchInstanceList);

        getSessionBean1().setLaunchInstInfo(launchInstanceInfo);
        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        return "launchInst";
    }
    //-------------------------------------------------------------------------

    public String editAMILaunchPermisson_action() {

        Map ec2AMILaunchPermissionsInfo = new HashMap();
        ArrayList ec2AMILaunchPermissionsRowKeys = new ArrayList();
        PageAlert questionAlert = new PageAlert();
        String detailMessage = new String();
        RowKey rowKey = null;

        saveTableStates();

        int selectedRows = getTrg_EC2_Images().getSelectedRowsCount();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No AMIs are selected.");
            detailMessage = detailMessage + "Please select at least one AMI to manage.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            getSessionBean1().setUserVisibleConnectBtn(false);
            return "infoAndReturn";
        }

        RowKey[] selectedRowKeys = getTrg_EC2_Images().getSelectedRowKeys();
        Properties awsProps = getSessionBean1().getAWSProps();
        ArrayList imageIDsList = new ArrayList();

        for (int i = 0; i < selectedRowKeys.length; i++) {

            String rowId = selectedRowKeys[i].getRowId();
            rowKey = getSessionBean1().ec2SecurityGroupDataProvider.getRowKey(rowId);

            EC2Image ec2Image =
                    getSessionBean1().getEC2ImageDataProvider().getImage(rowKey);

            if (ec2Image.getimageOwnerId().equals(awsProps.get("aws.accountId"))) {
                ec2AMILaunchPermissionsRowKeys.add(rowKey);
                imageIDsList.add(ec2Image.getimageId() + " ("
                        + ec2Image.getImageRegion() + ")");
            }

            if (!imageIDsList.isEmpty()) {
                Collections.sort(imageIDsList);
                Option[] imageIDsOptions = new Option[imageIDsList.size()];
                for (int j = 0; j < imageIDsList.size(); j++) {
                    imageIDsOptions[j] = new Option(imageIDsList.get(j));
                }
                getSessionBean1().setImageIDRowsSelected(imageIDsOptions);
            } else {
                questionAlert.setType("information");
                questionAlert.setTitle(" " + "No AMIs that you own are selected.");
                detailMessage = detailMessage + "Please select at least one AMI that you own to manage.";
                getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
                getSessionBean1().setPageAlertDetailMessage(detailMessage);
                getSessionBean1().setUserPageAlert(questionAlert);
                getSessionBean1().setUserVisibleContinueBtn(false);
                getSessionBean1().setUserVisibleConnectBtn(false);
                return "infoAndReturn";
            }
        }

        ec2AMILaunchPermissionsInfo.put("rowKeys", ec2AMILaunchPermissionsRowKeys);
        getSessionBean1().setEc2AMILaunchPermissionsInfo(ec2AMILaunchPermissionsInfo);

        return "editAMILaunchPermissions";
    }

    //-------------------------------------------------------------------------
    public String regAMI_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        saveTableStates();
        return "regAMIs";
    }

    //-------------------------------------------------------------------------
    public String deregAMI_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.

        PageAlert questionAlert = new PageAlert();
        String detailMessage = new String();
        saveTableStates();

        int selectedRows = getTrg_EC2_Images().getSelectedRowsCount();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No Images are selected.");
            detailMessage = detailMessage + "Please select at least one image to de-regiseter.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            return "infoAndReturn";
        }

        RowKey[] selectedRowKeys = getTrg_EC2_Images().getSelectedRowKeys();
        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        for (int i = 0; i < selectedRowKeys.length; i++) {
            String rowId = selectedRowKeys[i].getRowId();
            RowKey rowKey = getSessionBean1().getEC2ImageDataProvider().getRowKey(rowId);
            EC2Image ec2Image = getSessionBean1().getEC2ImageDataProvider().getImage(rowKey);
            detailMessage = detailMessage + ec2Image.getimageId() + "\n";
        }

        questionAlert.setType("information");
        questionAlert.setTitle(" " + "AMIs will be de-registered.");
        questionAlert.setSummary("Please press Continue to de-register AMIs.");
        questionAlert.setDetail("The AMIs shown below will be de-registered.\nUse the scroll bar, if available, to view all.");

        getSessionBean1().setPageAlertAWSActionType("deregAMIs");
        getSessionBean1().setPageAlertDetailMessage(detailMessage);
        getSessionBean1().setUserPageAlert(questionAlert);
        getSessionBean1().setUserVisibleContinueBtn(true);
        getSessionBean1().setUserVisibleConnectBtn(false);

        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        return "deregAMIs";
    }
    //-------------------------------------------------------------------------

    public String terminateInstance_action() {
        String detailMessage = new String();
        PageAlert questionAlert = new PageAlert();
        saveTableStates();

        int selectedRows = getTrg_EC2_Instances().getSelectedRowsCount();
        boolean atLeastOneRunningInstance = false;
        RowKey[] selectedRowKeys = getTrg_EC2_Instances().getSelectedRowKeys();

        for (int i = 0; i < selectedRowKeys.length; i++) {
            String rowId = selectedRowKeys[i].getRowId();
            RowKey rowKey = getSessionBean1().getEC2InstanceDataProvider().getRowKey(rowId);
            EC2Instance ec2Instance = getSessionBean1().getEC2InstanceDataProvider().getInstance(rowKey);
            if ((ec2Instance.getstateName().equals("running")) || (ec2Instance.getstateName().equals("pending"))) {
                atLeastOneRunningInstance = true;
                detailMessage = detailMessage + ec2Instance.getinstanceId();
                if (ec2Instance.getinstname() != null) {
                    if (!ec2Instance.getinstname().equals("")) {
                        detailMessage = detailMessage + " (" + ec2Instance.getinstname() + ")";
                    }
                }
                detailMessage = detailMessage + "\n";
            }
        }

        if ((selectedRows == 0) || (!atLeastOneRunningInstance)) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No running or pending instances are selected.");
            detailMessage = detailMessage + "Please select at least one running or pending instance to terminate.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            getSessionBean1().setUserVisibleConnectBtn(false);

            return "infoAndReturn";
        }

        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        questionAlert.setType("warning");
        questionAlert.setTitle(" " + "Instances will be Terminated!");
        questionAlert.setSummary("Please press Continue to terminate instances. This operation can not be undone.");
        questionAlert.setDetail("The instances shown below will be terminated.\nUse the scroll bar, if available, to view all.");

        getSessionBean1().setPageAlertAWSActionType("terminateInstance");
        getSessionBean1().setPageAlertDetailMessage(detailMessage);
        getSessionBean1().setUserPageAlert(questionAlert);
        getSessionBean1().setUserVisibleContinueBtn(true);
        getSessionBean1().setUserVisibleConnectBtn(false);

        return "terminateInst";
    }
    //-------------------------------------------------------------------------

    public String rebootInstance_action() {
        String detailMessage = new String();
        PageAlert questionAlert = new PageAlert();
        saveTableStates();

        boolean atLeastOneRunningInstance = false;
        int selectedRows = getTrg_EC2_Instances().getSelectedRowsCount();
        RowKey[] selectedRowKeys = getTrg_EC2_Instances().getSelectedRowKeys();

        for (int i = 0; i < selectedRowKeys.length; i++) {
            String rowId = selectedRowKeys[i].getRowId();
            RowKey rowKey = getSessionBean1().getEC2InstanceDataProvider().getRowKey(rowId);
            EC2Instance ec2Instance = getSessionBean1().getEC2InstanceDataProvider().getInstance(rowKey);
            if (ec2Instance.getstateName().equals("running")) {
                atLeastOneRunningInstance = true;
                detailMessage = detailMessage + ec2Instance.getinstanceId();
                if (ec2Instance.getinstname() != null) {
                    if (!ec2Instance.getinstname().equals("")) {
                        detailMessage = detailMessage + " (" + ec2Instance.getinstname() + ")";
                    }
                }
                detailMessage = detailMessage + "\n";
            }
        }

        if ((selectedRows == 0) || (!atLeastOneRunningInstance)) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No running instances are selected.");
            detailMessage = detailMessage + "Please select at least one running instance to reboot.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            getSessionBean1().setUserVisibleConnectBtn(false);

            return "infoAndReturn";
        }

        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        questionAlert.setType("warning");
        questionAlert.setTitle(" " + "Instances will be Rebooted!");
        questionAlert.setSummary("Please press Continue to reboot instances. This operation can not be undone.");
        questionAlert.setDetail("The instances shown below will be rebooted.\nUse the scroll bar, if available, to view all.");

        getSessionBean1().setPageAlertAWSActionType("rebootInstance");
        getSessionBean1().setPageAlertDetailMessage(detailMessage);
        getSessionBean1().setUserPageAlert(questionAlert);
        getSessionBean1().setUserVisibleContinueBtn(true);
        getSessionBean1().setUserVisibleConnectBtn(false);

        return "rebootInst";
    }
    //-------------------------------------------------------------------------

    public String getConsoleOutput_action() {
        String detailMessage = new String();
        PageAlert questionAlert = new PageAlert();
        saveTableStates();

        int selectedRows = getTrg_EC2_Instances().getSelectedRowsCount();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No Instances are selected.");
            detailMessage = detailMessage + "Please select at least one Instance to retrieve console output.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            getSessionBean1().setUserVisibleConnectBtn(false);

            return "infoAndReturn";
        }

        RowKey[] selectedRowKeys = getTrg_EC2_Instances().getSelectedRowKeys();

        for (int i = 0; i < selectedRowKeys.length; i++) {
            String rowId = selectedRowKeys[i].getRowId();
            RowKey rowKey = getSessionBean1().getEC2InstanceDataProvider().getRowKey(rowId);
            EC2Instance ec2Instance = getSessionBean1().getEC2InstanceDataProvider().getInstance(rowKey);
            detailMessage = detailMessage + ec2Instance.getinstanceId();
            if (ec2Instance.getinstname() != null) {
                if (!ec2Instance.getinstname().equals("")) {
                    detailMessage = detailMessage + " (" + ec2Instance.getinstname() + ")";
                }
            }
            detailMessage = detailMessage + "\n";
        }

        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        questionAlert.setType("information");
        questionAlert.setTitle(" " + "Console Output will be retrieved!");
        questionAlert.setSummary("Please press Continue to retrieve console output.");
        questionAlert.setDetail("Console output will be retrieved for the instances shown below.\nUse the scroll bar, if available, to view all.");

        getSessionBean1().setPageAlertAWSActionType("getConsoleOutput");
        getSessionBean1().setPageAlertDetailMessage(detailMessage);
        getSessionBean1().setUserPageAlert(questionAlert);
        getSessionBean1().setUserVisibleContinueBtn(true);
        getSessionBean1().setUserVisibleConnectBtn(false);

        return "getConsole";
    }
    //-------------------------------------------------------------------------

    public String sshToInstance_action() {
        String detailMessage = new String();
        PageAlert questionAlert = new PageAlert();
        saveTableStates();

        int selectedRows = getTrg_EC2_Instances().getSelectedRowsCount();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No Instances are selected.");
            detailMessage = detailMessage + "Please select at least one instance to connect to using ssh.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            getSessionBean1().setUserVisibleConnectBtn(false);

            return "infoAndReturn";
        }

        RowKey[] selectedRowKeys = getTrg_EC2_Instances().getSelectedRowKeys();
        Option[] instanceIDs = new Option[selectedRowKeys.length];

        for (int i = 0; i < selectedRowKeys.length; i++) {
            String rowId = selectedRowKeys[i].getRowId();
            RowKey rowKey = getSessionBean1().getEC2InstanceDataProvider().getRowKey(rowId);
            EC2Instance ec2Instance = getSessionBean1().getEC2InstanceDataProvider().getInstance(rowKey);
            instanceIDs[i] = new Option(ec2Instance.getinstanceId());
        }

        getSessionBean1().setInstanceIDRowsSelected(instanceIDs);
        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        return "sshToInstances";
    }
    //-------------------------------------------------------------------------

    public String updateInstance_action() {
        saveTableStates();
        String detailMessage = new String();
        PageAlert questionAlert = new PageAlert();

        int selectedRows = getTrg_EC2_Instances().getSelectedRowsCount();
        RowKey[] selectedRowKeys = getTrg_EC2_Instances().getSelectedRowKeys();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No instances are selected.");
            detailMessage = detailMessage + "Please select at least one instance to update.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            getSessionBean1().setUserVisibleConnectBtn(false);

            return "infoAndReturn";
        }

        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        return "updateInst";
    }

    //-------------------------------------------------------------------------
    public String createVolume_action() {
        saveTableStates();
        return "createVol";
    }

    //-------------------------------------------------------------------------
    public String attachVolumes_action() {

        Map attachVolInfo = new HashMap();
        ArrayList attachVolList = new ArrayList();
        PageAlert questionAlert = new PageAlert();
        String detailMessage = new String();
        saveTableStates();

        int selectedRows = getTrg_EBS_Volumes().getSelectedRowsCount();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No Volumes are selected.");
            detailMessage = detailMessage + "Please select at least one available volume to attach.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            getSessionBean1().setUserVisibleConnectBtn(false);
            return "infoAndReturn";
        }

        RowKey[] selectedRowKeys = getTrg_EBS_Volumes().getSelectedRowKeys();

        for (int i = 0; i < selectedRowKeys.length; i++) {
            String rowId = selectedRowKeys[i].getRowId();
            RowKey rowKey = getSessionBean1().getEBSVolumeDataProvider().getRowKey(rowId);
            EBSVolume ebsVolume = getSessionBean1().getEBSVolumeDataProvider().getVolume(rowKey);
            if (ebsVolume.getvstatus().equals("available")) {
                attachVolList.add(rowKey);
            }
        }

        if (attachVolList.size() == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No available Volumes are selected.");
            detailMessage = detailMessage + "Please select at least one available volume to attach.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            getSessionBean1().setUserVisibleConnectBtn(false);
            return "infoAndReturn";
        }

        getSessionBean1().setInstanceIDsOptions(
                getSessionBean1().ec2InstanceDataProvider.getInstanceIDsOptions());

        attachVolInfo.put("rowKeys", attachVolList);

        getSessionBean1().setAttachVolInfo(attachVolInfo);
        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        return "attachVol";
    }
    //-------------------------------------------------------------------------

    public String terminateVolume_action() {
        String detailMessage = new String();
        PageAlert questionAlert = new PageAlert();
        saveTableStates();

        int selectedRows = getTrg_EBS_Volumes().getSelectedRowsCount();
        boolean atLeastOneAvailableVol = false;
        RowKey[] selectedRowKeys = getTrg_EBS_Volumes().getSelectedRowKeys();

        for (int i = 0; i < selectedRowKeys.length; i++) {
            String rowId = selectedRowKeys[i].getRowId();
            RowKey rowKey = getSessionBean1().getEBSVolumeDataProvider().getRowKey(rowId);
            EBSVolume ebsVolume = getSessionBean1().getEBSVolumeDataProvider().getVolume(rowKey);
            if ((ebsVolume.getvstatus().equals("available"))) {
                atLeastOneAvailableVol = true;
                detailMessage = detailMessage + ebsVolume.getVolumeRegion() + ", ";
                detailMessage = detailMessage + ebsVolume.getvolumeId();
                if (ebsVolume.getvolname() != null) {
                    if (!ebsVolume.getvolname().equals("")) {
                        detailMessage = detailMessage + " (" + ebsVolume.getvolname() + ")";
                    }
                }
                detailMessage = detailMessage + "\n";
            }
        }

        if ((selectedRows == 0) || (!atLeastOneAvailableVol)) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No available volumes selected.");
            detailMessage = detailMessage + "Please select at least one available volume to terminate.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            getSessionBean1().setUserVisibleConnectBtn(false);

            return "infoAndReturn";
        }

        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        questionAlert.setType("warning");
        questionAlert.setTitle(" " + "Volumes will be Terminated!");
        questionAlert.setSummary("Please press Continue to terminate volumes. This operation can not be undone.");
        questionAlert.setDetail("The volumes listed below will be terminated.\nUse the scroll bar, if available, to view all.");

        getSessionBean1().setPageAlertAWSActionType("terminateVolume");
        getSessionBean1().setPageAlertDetailMessage(detailMessage);
        getSessionBean1().setUserPageAlert(questionAlert);
        getSessionBean1().setUserVisibleContinueBtn(true);
        getSessionBean1().setUserVisibleConnectBtn(false);
        return "terminateVol";
    }
    //-------------------------------------------------------------------------

    public String detachVolume_action() {
        Map detachVolInfo = new HashMap();
        String detailMessage = new String();
        PageAlert questionAlert = new PageAlert();
        ArrayList detachVolList = new ArrayList();
        int selectedRows = getTrg_EBS_Volumes().getSelectedRowsCount();
        saveTableStates();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No Volumes are selected.");
            detailMessage = detailMessage + "Please select at least one volume to detach.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            getSessionBean1().setUserVisibleConnectBtn(false);
            return "infoAndReturn";
        }

        RowKey[] selectedRowKeys = getTrg_EBS_Volumes().getSelectedRowKeys();

        for (int i = 0; i < selectedRowKeys.length; i++) {
            String rowId = selectedRowKeys[i].getRowId();
            RowKey rowKey = getSessionBean1().getEBSVolumeDataProvider().getRowKey(rowId);
            EBSVolume ebsVolume = getSessionBean1().getEBSVolumeDataProvider().getVolume(rowKey);
            if (ebsVolume.getvstatus().equals("in-use")) {
                detailMessage = detailMessage + ebsVolume.getvolumeId();
                if ((ebsVolume.getvolname() != null)
                        && (ebsVolume.getvstatus().equals("in-use"))) {
                    if (!ebsVolume.getvolname().equals("")) {
                        detailMessage = detailMessage + " (" + ebsVolume.getvolname() + ")";
                    }
                }
                detailMessage = detailMessage + "\n";
                detachVolList.add(rowKey);
            }
        }

        if (detachVolList.size() == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No in-use Volumes are selected.");
            detailMessage = detailMessage + "Please select at least one in-use volume to detach.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            getSessionBean1().setUserVisibleConnectBtn(false);
            return "infoAndReturn";
        }

        detachVolInfo.put("rowKeys", detachVolList);
        getSessionBean1().setDetachVolInfo(detachVolInfo);
        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        questionAlert.setType("warning");
        questionAlert.setTitle(" " + "Volumes will be Detached!");
        questionAlert.setSummary("Please press Continue to detach volumes.");
        questionAlert.setDetail("The volumes listed below will be detached.\nUse the scroll bar, if available, to view all.");

        getSessionBean1().setPageAlertAWSActionType("detachVolume");
        getSessionBean1().setPageAlertDetailMessage(detailMessage);
        getSessionBean1().setUserPageAlert(questionAlert);
        getSessionBean1().setUserVisibleContinueBtn(true);
        getSessionBean1().setUserVisibleConnectBtn(false);
        return "detachVol";
    }
    //-------------------------------------------------------------------------

    public String updateVolume_action() {
        saveTableStates();
        String detailMessage = new String();
        PageAlert questionAlert = new PageAlert();

        int selectedRows = getTrg_EBS_Volumes().getSelectedRowsCount();
        RowKey[] selectedRowKeys = getTrg_EBS_Volumes().getSelectedRowKeys();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No volumes are selected.");
            detailMessage = detailMessage + "Please select at least one volume to update.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            getSessionBean1().setUserVisibleConnectBtn(false);

            return "infoAndReturn";
        }

        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        return "updateVol";
    }

    //-------------------------------------------------------------------------
    public String createSnapshot_action() {
        String detailMessage = new String();
        PageAlert questionAlert = new PageAlert();
        saveTableStates();

        int selectedRows = getTrg_EBS_Volumes().getSelectedRowsCount();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No Volumes are selected.");
            detailMessage = detailMessage + "Please select at least one volume for which to create a Snapshot.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            return "infoAndReturn";
        }

        RowKey[] selectedRowKeys = getTrg_EBS_Volumes().getSelectedRowKeys();

        for (int i = 0; i < selectedRowKeys.length; i++) {
            String rowId = selectedRowKeys[i].getRowId();
            RowKey rowKey = getSessionBean1().getEBSVolumeDataProvider().getRowKey(rowId);
            EBSVolume ebsVolume = getSessionBean1().getEBSVolumeDataProvider().getVolume(rowKey);
            detailMessage = detailMessage + ebsVolume.getvolumeId();
            if (ebsVolume.getvolname() != null) {
                if (!ebsVolume.getvolname().equals("")) {
                    detailMessage = detailMessage + " (" + ebsVolume.getvolname() + ")";
                }
            }
            detailMessage = detailMessage + "\n";
        }
        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        questionAlert.setType("information");
        questionAlert.setTitle(" " + "Snapshots will be Created!");
        questionAlert.setSummary("Please press Continue to create Snapshots.");
        questionAlert.setDetail("Snapshots will be created for the volumes listed below.\nUse the scroll bar, if available, to view all.");

        getSessionBean1().setPageAlertAWSActionType("createSnapshot");
        getSessionBean1().setPageAlertDetailMessage(detailMessage);
        getSessionBean1().setUserPageAlert(questionAlert);
        getSessionBean1().setUserVisibleContinueBtn(true);
        getSessionBean1().setUserVisibleConnectBtn(false);
        getSessionBean1().setUserVisibleCloneMetadataFromVol(true);
        return "createSnap";
    }
    //-------------------------------------------------------------------------

    public String terminateSnapshot_action() {

        PageAlert questionAlert = new PageAlert();
        String detailMessage = new String();
        saveTableStates();

        int selectedRows = getTrg_EBS_Snapshots().getSelectedRowsCount();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No Snapshots are selected.");
            detailMessage = detailMessage + "Please select at least one Snapshot to terminate.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            getSessionBean1().setUserVisibleConnectBtn(false);
            return "infoAndReturn";
        }

        RowKey[] selectedRowKeys = getTrg_EBS_Snapshots().getSelectedRowKeys();

        for (int i = 0; i < selectedRowKeys.length; i++) {
            String rowId = selectedRowKeys[i].getRowId();
            RowKey rowKey = getSessionBean1().getEBSSnapshotDataProvider().getRowKey(rowId);
            EBSSnapshot ebsSnapshot = getSessionBean1().getEBSSnapshotDataProvider().getSnapshot(rowKey);
            detailMessage = detailMessage + ebsSnapshot.getsnapshotId();
            if (ebsSnapshot.getsnapname() != null) {
                if (!ebsSnapshot.getsnapname().equals("")) {
                    detailMessage = detailMessage + "(" + ebsSnapshot.getsnapname() + ")";
                }
            }
            detailMessage = detailMessage + "\n";
        }

        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        questionAlert.setType("warning");
        questionAlert.setTitle(" " + "Snapshots will be Terminated!");
        questionAlert.setSummary("Please press Continue to terminate snapshots. This operation can not be undone.");
        questionAlert.setDetail("The snapshots listed below will be terminated.\nUse the scroll bar, if available, to view all.");

        getSessionBean1().setPageAlertAWSActionType("terminateSnapshot");
        getSessionBean1().setPageAlertDetailMessage(detailMessage);
        getSessionBean1().setUserPageAlert(questionAlert);
        getSessionBean1().setUserVisibleContinueBtn(true);
        getSessionBean1().setUserVisibleConnectBtn(false);
        return "terminateSnap";
    }

    //-------------------------------------------------------------------------
    public String createVolsFromSnaps_action() {

        Map createVolsFromSnapsInfo = new HashMap();
        ArrayList createVolsFromSnapsList = new ArrayList();
        PageAlert questionAlert = new PageAlert();
        String detailMessage = new String();
        saveTableStates();

        int selectedRows = getTrg_EBS_Snapshots().getSelectedRowsCount();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No Snapshots are selected.");
            detailMessage = detailMessage + "Please select at least one snapshot to create volumes.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            getSessionBean1().setUserVisibleConnectBtn(false);
            return "infoAndReturn";
        }

        RowKey[] selectedRowKeys = getTrg_EBS_Snapshots().getSelectedRowKeys();

        for (int i = 0; i < selectedRowKeys.length; i++) {
            String rowId = selectedRowKeys[i].getRowId();
            RowKey rowKey = getSessionBean1().getEBSSnapshotDataProvider().getRowKey(rowId);
            createVolsFromSnapsList.add(rowKey);
        }

        createVolsFromSnapsInfo.put("snapsRowKeys", createVolsFromSnapsList);

        getSessionBean1().setCreateVolsFromSnapsInfo(createVolsFromSnapsInfo);
        getSessionBean1().setSelectedRowKeys(selectedRowKeys);
        getSessionBean1().setUserVisibleCloneMetadataFromSnap(true);

        return "createVolsFromSnapsStart";

    }
    //-------------------------------------------------------------------------

    public String updateSnapshot_action() {
        saveTableStates();
        String detailMessage = new String();
        PageAlert questionAlert = new PageAlert();

        int selectedRows = getTrg_EBS_Snapshots().getSelectedRowsCount();
        RowKey[] selectedRowKeys = getTrg_EBS_Snapshots().getSelectedRowKeys();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No snapshots are selected.");
            detailMessage = detailMessage + "Please select at least one snapshot to update.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            getSessionBean1().setUserVisibleConnectBtn(false);

            return "infoAndReturn";
        }

        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        return "updateSnap";
    }

    //-------------------------------------------------------------------------
    public String s3BucketAdd_action() {
        saveTableStates();
        return "s3BucketAdd";
    }

    //-------------------------------------------------------------------------
    public String s3BucketDelete_action() {
        Map s3ManageObjectsInfo = new HashMap();
        ArrayList s3ManageObjectsRowKeys = new ArrayList();
        PageAlert questionAlert = new PageAlert();
        String detailMessage = new String();
        RowKey rowKey = null;
        saveTableStates();

        int selectedRows = getTrg_S3Buckets().getSelectedRowsCount();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No Buckets are selected.");
            detailMessage = detailMessage + "Please select at least one Bucket to delete.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            getSessionBean1().setUserVisibleConnectBtn(false);
            return "infoAndReturn";
        }

        RowKey[] selectedRowKeys = getTrg_S3Buckets().getSelectedRowKeys();

        for (int i = 0; i < selectedRowKeys.length; i++) {
            String rowId = selectedRowKeys[i].getRowId();
            rowKey = getSessionBean1().getS3StorageBucketDataProvider().getRowKey(rowId);
            S3StorageBucket s3StorageBucket = getSessionBean1().getS3StorageBucketDataProvider().getS3StorageBucket(rowKey);
            detailMessage = detailMessage + s3StorageBucket.getname() + "\n";
            s3ManageObjectsRowKeys.add(rowKey);
        }

        s3ManageObjectsInfo.put("rowKeys", s3ManageObjectsRowKeys);
        getSessionBean1().setSelectedRowKeys(selectedRowKeys);
        getSessionBean1().setS3ManageObjectsInfo(s3ManageObjectsInfo);

        questionAlert.setType("warning");
        questionAlert.setTitle(" " + "Buckets will be deleted!");
        questionAlert.setSummary("Please press Continue to delete buckets. This operation can not be undone.");
        questionAlert.setDetail("The buckets listed below will be deleted.\nUse the scroll bar, if available, to view all.");

        getSessionBean1().setPageAlertAWSActionType("s3BucketDelete");
        getSessionBean1().setPageAlertDetailMessage(detailMessage);
        getSessionBean1().setUserPageAlert(questionAlert);
        getSessionBean1().setUserVisibleContinueBtn(true);
        getSessionBean1().setUserVisibleConnectBtn(false);

        return "s3BucketDelete";
    }

    //-------------------------------------------------------------------------
    public String s3ManageObjects_action() {

        Map s3ManageObjectsInfo = new HashMap();
        ArrayList s3ManageObjectsRowKeys = new ArrayList();
        PageAlert questionAlert = new PageAlert();
        String detailMessage = new String();
        RowKey rowKey = null;
        saveTableStates();

        int selectedRows = getTrg_S3Buckets().getSelectedRowsCount();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No Buckets are selected.");
            detailMessage = detailMessage + "Please select at least one Bucket to manage.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            getSessionBean1().setUserVisibleConnectBtn(false);
            return "infoAndReturn";
        }

        RowKey[] selectedRowKeys = getTrg_S3Buckets().getSelectedRowKeys();

        for (int i = 0; i < selectedRowKeys.length; i++) {
            String rowId = selectedRowKeys[i].getRowId();
            rowKey = getSessionBean1().getS3StorageBucketDataProvider().getRowKey(rowId);
            s3ManageObjectsRowKeys.add(rowKey);
        }

        s3ManageObjectsInfo.put("rowKeys", s3ManageObjectsRowKeys);
        getSessionBean1().setS3ManageObjectsInfo(s3ManageObjectsInfo);
        return "s3ManageObjects";
    }
    //-------------------------------------------------------------------------

    public String addEC2IP_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        saveTableStates();

        //getSessionBean1().getEc2IPDataProvider().createEC2IP();
        //refreshView_EC2IPs_action();

        return "addEC2IP";
    }
    //-------------------------------------------------------------------------

    public String releaseEC2IP_action() {

        PageAlert questionAlert = new PageAlert();
        String detailMessage = new String();
        saveTableStates();

        int selectedRows = getTrg_EC2_IPs().getSelectedRowsCount();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No Elastic IPs are selected.");
            detailMessage = detailMessage + "Please select at least one Elastic IP to release.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            return "infoAndReturn";
        }

        RowKey[] selectedRowKeys = getTrg_EC2_IPs().getSelectedRowKeys();
        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        for (int i = 0; i < selectedRowKeys.length; i++) {
            String rowId = selectedRowKeys[i].getRowId();
            RowKey rowKey = getSessionBean1().getEc2IPDataProvider().getRowKey(rowId);
            EC2IP ec2ip = getSessionBean1().getEc2IPDataProvider().getEC2IP(rowKey);
            detailMessage = detailMessage + String.format("%-16s", ec2ip.getpublicip());

            if (ec2ip.geteipname() != null) {
                if (!ec2ip.geteipname().equals("")) {
                    detailMessage = detailMessage + " (" + ec2ip.geteipname() + ")";
                }
            }
            detailMessage = detailMessage + "\n";
        }

        questionAlert.setType("warning");
        questionAlert.setTitle(" " + "Elastic IPs will be released.");
        questionAlert.setSummary("Please press Continue to release Elastic IPs. This operation can not be undone.");
        questionAlert.setDetail("The Elastic IPs shown below will be released.\nUse the scroll bar, if available, to view all.");

        getSessionBean1().setPageAlertAWSActionType("releaseEC2IPs");
        getSessionBean1().setPageAlertDetailMessage(detailMessage);
        getSessionBean1().setUserPageAlert(questionAlert);
        getSessionBean1().setUserVisibleContinueBtn(true);
        getSessionBean1().setUserVisibleConnectBtn(false);

        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        return "releaseEC2IP";
    }
    //-------------------------------------------------------------------------

    public String associateEC2IP_action() {

        PageAlert questionAlert = new PageAlert();
        String detailMessage = new String();
        saveTableStates();

        int selectedRows = getTrg_EC2_IPs().getSelectedRowsCount();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No Elastic IPs are selected.");
            detailMessage = detailMessage + "Please select one Elastic IP to associate.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            return "infoAndReturn";
        }

        if (selectedRows > 1) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "More than one Elastic IP is selected.");
            detailMessage = detailMessage + "Please select only one Elastic IP to associate.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            return "infoAndReturn";
        }

        RowKey[] selectedRowKeys = getTrg_EC2_IPs().getSelectedRowKeys();
        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        return "associateEC2IP";
    }
    //-------------------------------------------------------------------------

    public String disassociateEC2IP_action() {

        PageAlert questionAlert = new PageAlert();
        String detailMessage = new String();
        saveTableStates();

        int selectedRows = getTrg_EC2_IPs().getSelectedRowsCount();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No Elastic IPs are selected.");
            detailMessage = detailMessage + "Please select at least one Elastic IP to disassociate.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            return "infoAndReturn";
        }

        RowKey[] selectedRowKeys = getTrg_EC2_IPs().getSelectedRowKeys();
        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        for (int i = 0; i < selectedRowKeys.length; i++) {
            String rowId = selectedRowKeys[i].getRowId();
            RowKey rowKey = getSessionBean1().getEc2IPDataProvider().getRowKey(rowId);
            EC2IP ec2ip = getSessionBean1().getEc2IPDataProvider().getEC2IP(rowKey);
            detailMessage = detailMessage + String.format("%-16s", ec2ip.getpublicip());

            if (ec2ip.geteipname() != null) {
                if (!ec2ip.geteipname().equals("")) {
                    detailMessage = detailMessage + " (" + ec2ip.geteipname() + ")";
                }
            }
            detailMessage = detailMessage + "\n";
        }

        questionAlert.setType("information");
        questionAlert.setTitle(" " + "Elastic IPs will be disassociated from instances.");
        questionAlert.setSummary("Please press Continue to disassociate Elastic IPs.");
        questionAlert.setDetail("The Elastic IPs shown below will be disassociated from instances.\nUse the scroll bar, if available, to view all.");

        getSessionBean1().setPageAlertAWSActionType("disassociateEC2IPs");
        getSessionBean1().setPageAlertDetailMessage(detailMessage);
        getSessionBean1().setUserPageAlert(questionAlert);
        getSessionBean1().setUserVisibleContinueBtn(true);
        getSessionBean1().setUserVisibleConnectBtn(false);

        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        return "disassociateEC2IP";
    }

    //-------------------------------------------------------------------------
    public String updateEC2IP_action() {
        saveTableStates();
        String detailMessage = new String();
        PageAlert questionAlert = new PageAlert();

        int selectedRows = getTrg_EC2_IPs().getSelectedRowsCount();
        RowKey[] selectedRowKeys = getTrg_EC2_IPs().getSelectedRowKeys();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No Elastic IPs are selected.");
            detailMessage = detailMessage + "Please select at least one Elastic IP to update.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            getSessionBean1().setUserVisibleConnectBtn(false);

            return "infoAndReturn";
        }
        refreshView_Instances_action();
        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        return "updateEC2IP";
    }

    public String addSecurityGroup_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        saveTableStates();
        return "addSecurityGroup";
    }
    //-------------------------------------------------------------------------

    public String deleteSecurityGroup_action() {

        PageAlert questionAlert = new PageAlert();
        String detailMessage = new String();
        saveTableStates();

        int selectedRows = getTrg_EC2_SecurityGroups().getSelectedRowsCount();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No Security Groups are selected.");
            detailMessage = detailMessage + "Please select at least one Security Group to delete.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            return "infoAndReturn";
        }

        RowKey[] selectedRowKeys = getTrg_EC2_SecurityGroups().getSelectedRowKeys();
        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        for (int i = 0; i < selectedRowKeys.length; i++) {
            String rowId = selectedRowKeys[i].getRowId();
            RowKey rowKey = getSessionBean1().getEc2SecurityGroupDataProvider().getRowKey(rowId);
            EC2SecurityGroup ec2SecurityGroup = getSessionBean1().getEc2SecurityGroupDataProvider().getSecurityGroup(rowKey);
            detailMessage = detailMessage + ec2SecurityGroup.getName() + "\n";
        }

        questionAlert.setType("warning");
        questionAlert.setTitle(" " + "Security Groups will be deleted.");
        questionAlert.setSummary("Please press Continue to delete Security Groups. This operation can not be undone.");
        questionAlert.setDetail("The Security Groups shown below will be deleted.\nUse the scroll bar, if available, to view all.");

        getSessionBean1().setPageAlertAWSActionType("deleteSecurityGroups");
        getSessionBean1().setPageAlertDetailMessage(detailMessage);
        getSessionBean1().setUserPageAlert(questionAlert);
        getSessionBean1().setUserVisibleContinueBtn(true);
        getSessionBean1().setUserVisibleConnectBtn(false);

        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        return "deleteSecurityGroup";
    }

    //-------------------------------------------------------------------------
    //-------------------------------------------------------------------------
    public String editSecurityGroup_action() {

        Map ec2SecurityGroupsInfo = new HashMap();
        Map sgSelectedNamesMap = new HashMap();
        ArrayList sgSelectedNamesList = new ArrayList();
        ArrayList ec2IpPermissionsRowKeys = new ArrayList();
        PageAlert questionAlert = new PageAlert();
        String detailMessage = new String();
        RowKey rowKey = null;
        saveTableStates();

        int selectedRows = getTrg_EC2_SecurityGroups().getSelectedRowsCount();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No Security Groups are selected.");
            detailMessage = detailMessage + "Please select at least one Security Group to manage.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            getSessionBean1().setUserVisibleConnectBtn(false);
            return "infoAndReturn";
        }

        RowKey[] selectedRowKeys = getTrg_EC2_SecurityGroups().getSelectedRowKeys();

        for (int i = 0; i < selectedRowKeys.length; i++) {

            String rowId = selectedRowKeys[i].getRowId();
            rowKey = getSessionBean1().ec2SecurityGroupDataProvider.getRowKey(rowId);

            EC2SecurityGroup ec2SecurityGroup =
                    getSessionBean1().ec2SecurityGroupDataProvider.getSecurityGroup(rowKey);

            String ec2SecurityGroupRegionName = ec2SecurityGroup.getName()
                    + " (" + ec2SecurityGroup.getRegion() + ")";

            if (sgSelectedNamesMap.get(ec2SecurityGroupRegionName) == null) {
                sgSelectedNamesMap.put(ec2SecurityGroupRegionName, ec2SecurityGroup.getDescription());
                sgSelectedNamesList.add(ec2SecurityGroupRegionName);
            }
            ec2IpPermissionsRowKeys.add(rowKey);
        }

        Collections.sort(sgSelectedNamesList);

        ec2SecurityGroupsInfo.put("rowKeys", ec2IpPermissionsRowKeys);
        ec2SecurityGroupsInfo.put("selectednames", sgSelectedNamesList);
        getSessionBean1().setEc2SecurityGroupsInfo(ec2SecurityGroupsInfo);

        return "editSecurityGroup";
    }

    //-------------------------------------------------------------------------
    public String addKeyPair_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        saveTableStates();
        return "addKeypair";
    }
    //-------------------------------------------------------------------------

    public String deleteKeyPair_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.

        PageAlert questionAlert = new PageAlert();
        String detailMessage = new String();
        saveTableStates();

        int selectedRows = getTrg_EC2_Keypairs().getSelectedRowsCount();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No Keypairs are selected.");
            detailMessage = detailMessage + "Please select at least one Keypair to delete.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            return "infoAndReturn";
        }

        RowKey[] selectedRowKeys = getTrg_EC2_Keypairs().getSelectedRowKeys();
        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        for (int i = 0; i < selectedRowKeys.length; i++) {
            String rowId = selectedRowKeys[i].getRowId();
            RowKey rowKey = getSessionBean1().getEc2KeyPairDataProvider().getRowKey(rowId);
            EC2KeyPair ec2KeyPair = getSessionBean1().getEc2KeyPairDataProvider().getKeypair(rowKey);
            detailMessage = detailMessage + ec2KeyPair.getkeyName() + "\n";
        }

        questionAlert.setType("warning");
        questionAlert.setTitle(" " + "Keypairs will be deleted.");
        questionAlert.setSummary("Please press Continue to delete Keypairs. This operation can not be undone.");
        questionAlert.setDetail("The Keypairs shown below will be deleted.\nUse the scroll bar, if available, to view all.");

        getSessionBean1().setPageAlertAWSActionType("deleteKeypairs");
        getSessionBean1().setPageAlertDetailMessage(detailMessage);
        getSessionBean1().setUserPageAlert(questionAlert);
        getSessionBean1().setUserVisibleContinueBtn(true);
        getSessionBean1().setUserVisibleConnectBtn(false);

        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        return "deleteKeypairs";
    }
    //-------------------------------------------------------------------------

    public String addIPaddr_action() {
        saveTableStates();
        return "addKeypair";
    }
    //-------------------------------------------------------------------------

    public String deleteSDBItem_action() {

        PageAlert questionAlert = new PageAlert();
        String detailMessage = new String();
        saveTableStates();

        int selectedRows = getTrg_SDB_Items().getSelectedRowsCount();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No SDB Items are selected.");
            detailMessage = detailMessage + "Please select at least one SDB Item to delete.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            return "infoAndReturn";
        }

        RowKey[] selectedRowKeys = getTrg_SDB_Items().getSelectedRowKeys();
        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        for (int i = 0; i < selectedRowKeys.length; i++) {
            String rowId = selectedRowKeys[i].getRowId();
            RowKey rowKey = getSessionBean1().getSdbItemDataProvider().getRowKey(rowId);
            SDBItem sdbItem = getSessionBean1().getSdbItemDataProvider().getSDBItem(rowKey);

            detailMessage = detailMessage + sdbItem.getId();
            if (sdbItem.getName() != null) {
                if (!sdbItem.getName().equals("")) {
                    detailMessage = detailMessage + " (" + sdbItem.getName() + ")";
                }
            }
            detailMessage = detailMessage + "\n";
        }

        questionAlert.setType("warning");
        questionAlert.setTitle(" " + "Metadata items will be deleted from the Simple DB domain.");
        questionAlert.setSummary("Please press Continue to delete metadata items. This operation can not be undone.");
        questionAlert.setDetail("The metadata itmes shown below will be deleted form the Simple DB domain.\nUse the scroll bar, if available, to view all.");

        getSessionBean1().setPageAlertAWSActionType("deleteSDBItem");
        getSessionBean1().setPageAlertDetailMessage(detailMessage);
        getSessionBean1().setUserPageAlert(questionAlert);
        getSessionBean1().setUserVisibleContinueBtn(true);
        getSessionBean1().setUserVisibleConnectBtn(false);

        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        return "deleteSDBItem";
    }
    //-------------------------------------------------------------------------

    public String updateSDBItem_action() {
        saveTableStates();
        String detailMessage = new String();
        PageAlert questionAlert = new PageAlert();

        int selectedRows = getTrg_SDB_Items().getSelectedRowsCount();
        RowKey[] selectedRowKeys = getTrg_SDB_Items().getSelectedRowKeys();

        if (selectedRows == 0) {
            questionAlert.setType("information");
            questionAlert.setTitle(" " + "No SDB Items are selected.");
            detailMessage = detailMessage + "Please select at least one SDB Item to update.";
            getSessionBean1().setPageAlertAWSActionType("infoAndReturn");
            getSessionBean1().setPageAlertDetailMessage(detailMessage);
            getSessionBean1().setUserPageAlert(questionAlert);
            getSessionBean1().setUserVisibleContinueBtn(false);
            return "infoAndReturn";
        }

        getSessionBean1().setSelectedRowKeys(selectedRowKeys);

        return "updateItem";
    }

    public String AWS_User_Settings_Clear_action() {
        AWS_User_Settings_Clear();
        ddl_AWSNickNames.resetValue();
        getSessionBean1().setAwsNickNamesOptions(null);
        getSessionBean1().getAwsCredentialDataProvider().init();
        return null;
    }

    public String AWS_User_Settings_Clear() {
        getSessionBean1().setAWSProps(null);
        setAWSInitProps();
        setAWSSystemProps();

        str_AWS_Secret_Access_Key = null;
        tf_AWS_Access_Key.setText(null);
        tf_AWS_Secret_Access_Key.setPassword(null);
        tf_AWS_Account_ID.setText(null);
        tf_SimpleDBDomainName.setText(null);
        tf_SSH_User.setText(null);

        getSessionBean1().setEc2Connection(null);
        getSessionBean1().setS3StorageConnection(null);
        getSessionBean1().setSdbConnection(null);
        getSessionBean1().setAwsNickNameDefault(null);
        getSessionBean1().setVisAWSNickNamesDDL(false);

        setSDBFunctionsVisibleTables();
        checkEC2ConnectionStatusMsg();

        refreshView_Images_action();
        refreshView_Instances_action();
        refreshView_Volumes_action();
        refreshView_Snapshots_action();
        refreshView_KeyPairs_action();
        refreshView_SecurityGroups_action();
        refreshView_EC2IPs_action();
        refreshView_EC2Regions_action();
        refreshView_SDBItems_action();
        refreshView_S3Buckets_action();

        return null;
    }

    //Submit User Settings button is pushed
    public String AWS_User_Settings_Submit_action() {

        Properties awsProps = getSessionBean1().getAWSProps();

        if (tf_AWS_Access_Key.getText() != null) {
            awsProps.setProperty("aws.accessKey", (String) tf_AWS_Access_Key.getText());
            // Debug:
            // System.out.println("AWS key: " + (String) tf_AWS_Access_Key.getText() + "\n");
        } else {
            awsProps.setProperty("aws.accessKey", "");
        }

        str_AWS_Secret_Access_Key = awsProps.getProperty("aws.secretKey");

        if (tf_AWS_Secret_Access_Key.getText() != null) {
            if ((tf_AWS_Secret_Access_Key.getText().equals("")) && (!str_AWS_Secret_Access_Key.equals(""))) {
                awsProps.setProperty("aws.secretKey", str_AWS_Secret_Access_Key);
            } else {
                try {
                    char[] char_tf_AWS_Secret_Access_Key = (char[]) tf_AWS_Secret_Access_Key.getText();
                    awsProps.setProperty("aws.secretKey", String.valueOf(char_tf_AWS_Secret_Access_Key));
                    str_AWS_Secret_Access_Key = String.valueOf(char_tf_AWS_Secret_Access_Key);
                } catch (ClassCastException ex) {
                    awsProps.setProperty("aws.secretKey", (String) tf_AWS_Secret_Access_Key.getText());
                    str_AWS_Secret_Access_Key = (String) tf_AWS_Secret_Access_Key.getText();
                }
            }
        } else {
            awsProps.setProperty("aws.secretKey", "");
            str_AWS_Secret_Access_Key = null;
        }

        if (tf_AWS_Account_ID.getText() != null) {
            awsProps.setProperty("aws.accountId", (String) tf_AWS_Account_ID.getText());
        } else {
            awsProps.setProperty("aws.accountId", "");
        }

        String awsS3Server = (String) ddl_AWS_S3Server.getValue();
        if (awsS3Server != null) {
            awsProps.setProperty("aws.s3server", awsS3Server);
        } else {
            awsProps.setProperty("aws.s3server", "");
        }

        String awsSDBServer = (String) ddl_AWS_SDBServer.getValue();
        if (awsSDBServer != null) {
            awsProps.setProperty("aws.sdbserver", awsSDBServer);
        } else {
            awsProps.setProperty("aws.sdbserver", "");
        }

        if (tf_SimpleDBDomainName.getText() != null) {
            awsProps.setProperty("aws.sdbdomain", (String) tf_SimpleDBDomainName.getText());
        } else {
            awsProps.setProperty("aws.sdbdomain", "");
        }

        if (tf_SSH_User.getText() != null) {
            awsProps.setProperty("ssh.user", (String) tf_SSH_User.getText());
        } else {
            awsProps.setProperty("ssh.user", "");
        }

        if (cb_EC2ReadAMIs.isChecked()) {
            awsProps.setProperty("aws.readamis", (String) "true");
        } else {
            awsProps.setProperty("aws.readamis", "");
        }

        getSessionBean1().setAWSProps(awsProps);
        AWS_CreateEC2Connection(awsProps);
        AWS_CreateS3Connection(awsProps);
        AWS_CreateSDBConnection(awsProps);

        setSDBFunctionsVisibleTables();
        checkEC2ConnectionStatusMsg();

        if ((str_AWS_Secret_Access_Key != null) && (!str_AWS_Secret_Access_Key.equals(""))) {
            refreshView_Instances_action();
            refreshView_Volumes_action();
            refreshView_Snapshots_action();
            refreshView_KeyPairs_action();
            refreshView_SecurityGroups_action();
            refreshView_EC2IPs_action();
            refreshView_EC2Regions_action();
            refreshView_SDBItems_action();
            refreshView_S3Buckets_action();

            if (cb_EC2ReadAMIs.isChecked()) {
                refreshView_Images_action();
            }
            lp_UserSettingsMsg.setRendered(true);

        } else {
            lp_UserSettingsMsg.setRendered(false);
        }
        return null;
    }

    public String AWS_User_Settings_Upload_action() {

        UploadedFile uploadedFile = (UploadedFile) fu_AWS_Props.getUploadedFile();
        lp_EC2ConnectionMsg.setRendered(false);

        try {
            Thread.sleep(2000);
        } catch (InterruptedException ex) {
            Logger.getLogger(AWSMain.class.getName()).log(Level.SEVERE, null, ex);
        }

        AWS_User_Settings_Clear_action();

        if (uploadedFile == null) {
            setEc2conHtmlStatusMsg("No file selected");
            lp_EC2ConnectionMsg.setRendered(true);
            lp_SDBConnectionMsg.setRendered(false);
            return null;
        }

        if (uploadedFile.getAsString() == null) {
            setEc2conHtmlStatusMsg("No file selected");
            lp_EC2ConnectionMsg.setRendered(true);
            lp_SDBConnectionMsg.setRendered(false);
            return null;
        }

        if (uploadedFile.getAsString().equals("")) {
            setEc2conHtmlStatusMsg("No file selected");
            lp_EC2ConnectionMsg.setRendered(true);
            lp_SDBConnectionMsg.setRendered(false);
            return null;
        }

        String awsPropsFileText = uploadedFile.getAsString();
        getSessionBean1().setVisAWSNickNamesDDL(false);

        if (awsPropsFileText.contains("<?xml")) {

            String xmlError = processXMLProps(awsPropsFileText);

            if (xmlError != null) {
                setEc2conHtmlStatusMsg(xmlError);
                lp_EC2ConnectionMsg.setRendered(true);
                return null;
            }

        } else {
            Scanner scanner = new Scanner(awsPropsFileText);
            try {
                while (scanner.hasNextLine()) {
                    try {
                        processPropsLine(scanner.nextLine());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            } finally {
                scanner.close();
            }
        }

        Properties awsProps = getSessionBean1().getAWSProps();
        AWS_Update_User_Settings_Form(awsProps);
        getSessionBean1().setAWSProps(awsProps);

        return null;
    }

    public void setAWSxmlProps(String awsNickName) {

        Properties awsProps = getSessionBean1().getAWSProps();
        Map awsCredentialsMap = (HashMap) getSessionBean1().getAwsCredentialDataProvider().getAwsCredentialsMap();

        if (awsCredentialsMap != null) {

            AWSCredential awsCredential = (AWSCredential) awsCredentialsMap.get(awsNickName);

            if (awsCredential != null) {

                if (awsCredential.getAwsAccessKey() != null) {
                    awsProps.setProperty("aws.accessKey", awsCredential.getAwsAccessKey().trim());
                }

                if (awsCredential.getAwsSecretKey() != null) {
                    awsProps.setProperty("aws.secretKey", awsCredential.getAwsSecretKey().trim());
                    str_AWS_Secret_Access_Key = awsCredential.getAwsSecretKey().trim();
                }

                if (awsCredential.getAwsAccountId() != null) {
                    awsProps.setProperty("aws.accountId", awsCredential.getAwsAccountId().trim());
                }

                if (awsCredential.getAwsAccountNickName() != null) {
                    awsProps.setProperty("aws.accountNickName", awsCredential.getAwsAccountNickName().trim());
                }

                if (awsCredential.getAwsS3Server() != null) {
                    awsProps.setProperty("aws.s3server", awsCredential.getAwsS3Server().trim());
                }

                if (awsCredential.getAwsSDBdomain() != null) {
                    awsProps.setProperty("aws.sdbdomain", awsCredential.getAwsSDBdomain().trim());
                }

                if (awsCredential.getAwsReadAMIs() != null) {
                    awsProps.setProperty("aws.readamis", awsCredential.getAwsReadAMIs().trim());
                }

                if (awsCredential.getSshUser() != null) {
                    awsProps.setProperty("ssh.user", awsCredential.getSshUser().trim());
                }
            }
        }
        getSessionBean1().setAWSProps(awsProps);
    }

    protected void processPropsLine(String aLine) throws Exception {

        Scanner scanner = new Scanner(aLine);
        scanner.useDelimiter("=");

        Properties awsProps = getSessionBean1().getAWSProps();

        if (scanner.hasNext()) {
            String name = scanner.next();
            String value = scanner.next();
            if (name.trim().equals("aws.accessKey")) {
                awsProps.setProperty("aws.accessKey", value.trim());
            } else if (name.trim().equals("aws.secretKey")) {
                awsProps.setProperty("aws.secretKey", value.trim());
                str_AWS_Secret_Access_Key = value.trim();
            } else if (name.trim().equals("aws.accountId")) {
                awsProps.setProperty("aws.accountId", value.trim());
            } else if (name.trim().equals("aws.accountNickName")) {
                awsProps.setProperty("aws.accountNickName", value.trim());
            } else if (name.trim().equals("aws.server")) {
                awsProps.setProperty("aws.server", value.trim());
            } else if (name.trim().equals("aws.s3server")) {
                awsProps.setProperty("aws.s3server", value.trim());
            } else if (name.trim().equals("aws.sdbdomain")) {
                awsProps.setProperty("aws.sdbdomain", value.trim());
            } else if (name.trim().equals("ssh.user")) {
                awsProps.setProperty("ssh.user", value.trim());
            } else if (name.trim().equals("aws.readamis")) {
                awsProps.setProperty("aws.readamis", value.trim());
            }
        } else {
            //info("Empty or invalid line. Unable to process.");
        }

        scanner.close();
        getSessionBean1().setAWSProps(awsProps);
    }

    public void setAWSInitProps() {

        if (getSessionBean1().getAWSProps() == null) {

            Properties awsProps = new Properties();

            awsProps.setProperty("aws.accessKey", "");
            awsProps.setProperty("aws.secretKey", "");
            awsProps.setProperty("aws.accountId", "");
            awsProps.setProperty("aws.accountNickName", "");
            awsProps.setProperty("aws.server", "");
            awsProps.setProperty("aws.s3server", "");
            awsProps.setProperty("aws.sdbdomain", "");
            awsProps.setProperty("aws.readamis", "");
            awsProps.setProperty("ssh.user", "");

            getSessionBean1().setAWSProps(awsProps);
            lp_UserSettingsMsg.setRendered(false);
            lp_EC2ConnectionMsg.setRendered(false);
            lp_SDBConnectionMsg.setRendered(false);

            setAWSSystemProps();
        }
    }

    public void setAWSSystemProps() {
       
        BufferedReader xmlFileIn = null;
        String xmlFileStr = null;
        String xmlError = null;
        File propsFile = null;

        FacesContext context = FacesContext.getCurrentInstance();
        ServletContext sc = (ServletContext) context.getExternalContext().getContext();

        try {
            propsFile = new File(sc.getRealPath("/resources/props/systemprops.xml"));
        } catch (NullPointerException  ex) {
            Logger.getLogger(AWSMain.class.getName()).log(Level.WARNING, null, ex);
            return;
        }

        try {
            xmlFileIn = new BufferedReader(new InputStreamReader(new FileInputStream(propsFile)));
        } catch (FileNotFoundException ex) {
            Logger.getLogger(AWSMain.class.getName()).log(Level.WARNING, null, ex);
        }

        if (xmlFileIn != null) {
            xmlFileStr = new String();
            String xmkLineStr = null;
            try {
                while ((xmkLineStr = xmlFileIn.readLine()) != null) {
                    xmlFileStr = xmlFileStr + xmkLineStr;
                }
                xmlFileIn.close();
            } catch (IOException ex) {
                Logger.getLogger(AWSMain.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

        if (xmlFileStr != null) {
            xmlError = processXMLProps(xmlFileStr);
            if (xmlError != null) {
                setEc2conHtmlStatusMsg(xmlError);
                lp_EC2ConnectionMsg.setRendered(true);
            }
        }
    }

    public String processXMLProps(String xmlString) {

        String awsNickName = null;
        String xmlError = null;

        xmlError = getSessionBean1().getAwsCredentialDataProvider().parseXmlString(xmlString);
        if (xmlError != null) {
            return xmlError;
        }

        xmlError = getSessionBean1().getEc2RegionDataProvider().parseXmlString(xmlString);
        if (xmlError != null) {
            return xmlError;
        }

        xmlError = getSessionBean1().getS3StorageServerDataProvider().parseXmlString(xmlString);
        if (xmlError != null) {
            return xmlError;
        }

        xmlError = getSessionBean1().getSdbServerDataProvider().parseXmlString(xmlString);
        if (xmlError != null) {
            return xmlError;
        }

        //---------------------------------------------------------
        HashMap ec2RegionsInfo = getSessionBean1().getEc2RegionDataProvider().getEC2RegionsMap();
        Option[] ec2RegionServerOptions = null;

        if (ec2RegionsInfo != null) {

            Collection ec2Regions = ec2RegionsInfo.values();
            ec2RegionServerOptions = new Option[ec2Regions.size()];
            Iterator itr = ec2Regions.iterator();

            int i = 0;
            while (itr.hasNext()) {
                EC2Region ec2Region = (EC2Region) itr.next();
                ec2RegionServerOptions[i] = new Option((String) ec2Region.getRegionName(),
                        (String) ec2Region.getRegionDisplayName());
                i++;
            }
        } else {
            ec2RegionServerOptions = new Option[3];
            ec2RegionServerOptions[0] = new Option("eu-west-1", "eu-west-1");
            ec2RegionServerOptions[1] = new Option("us-east-1", "us-east-1");
            ec2RegionServerOptions[2] = new Option("us-east-1", "us-east-1");
        }
        getSessionBean1().setEc2RegionServerOptions(ec2RegionServerOptions);

        //---------------------------------------------------------
        HashMap s3ServersInfo = getSessionBean1().getS3StorageServerDataProvider().getS3ServersMap();
        Option[] s3ServerOptions = null;

        if (s3ServersInfo != null) {

            Collection s3Servers = s3ServersInfo.values();
            s3ServerOptions = new Option[s3Servers.size()];
            Iterator itr = s3Servers.iterator();

            int i = 0;
            while (itr.hasNext()) {
                S3StorageServer s3Server = (S3StorageServer) itr.next();
                s3ServerOptions[i] = new Option((String) s3Server.getS3Server(),
                        (String) s3Server.getS3ServerName());
                i++;
            }
        } else {
            s3ServerOptions = new Option[1];
            s3ServerOptions[0] = new Option("s3.amazonaws.com", "s3.amazonaws.com");
        }
        getSessionBean1().setS3ServerOptions(s3ServerOptions);
        //---------------------------------------------------------
        HashMap sdbServersInfo = getSessionBean1().getSdbServerDataProvider().getSDBServersMap();
        Option[] sdbServerOptions = null;

        if (sdbServersInfo != null) {

            Collection sdbServers = sdbServersInfo.values();
            sdbServerOptions = new Option[sdbServers.size()];
            Iterator itr = sdbServers.iterator();

            int i = 0;
            while (itr.hasNext()) {
                SDBServer sdbServer = (SDBServer) itr.next();
                sdbServerOptions[i] = new Option((String) sdbServer.getServer(),
                        (String) sdbServer.getServerName());
                i++;
            }
        } else {
            sdbServerOptions = new Option[1];
            sdbServerOptions[0] = new Option("sdb.amazonaws.com", "sdb.amazonaws.com");
        }
        getSessionBean1().setSDBServerOptions(sdbServerOptions);

        //---------------------------------------------------------
        getSessionBean1().setAwsNickNamesOptions(
                getSessionBean1().getAwsCredentialDataProvider().getAWSNickNamesOptions());

        Option[] awsNickNamesOptions = getSessionBean1().getAwsNickNamesOptions();

        if (awsNickNamesOptions != null) {
            if (awsNickNamesOptions.length > 0) {
                awsNickName = (String) awsNickNamesOptions[0].getValue();
                getSessionBean1().setVisAWSNickNamesDDL(true);
                if (awsNickName != null) {
                    setAWSxmlProps(awsNickName);
                }
            }
        }

        return xmlError;
    }

    public void AWS_Update_User_Settings_Form(Properties awsProps) {

        if (awsProps != null) {

            tf_AWS_Access_Key.setText(awsProps.getProperty("aws.accessKey"));

            tf_AWS_Secret_Access_Key.setPassword(awsProps.getProperty("aws.secretKey").toCharArray());
            tf_AWS_Account_ID.setText(awsProps.getProperty("aws.accountId"));
            tf_SimpleDBDomainName.setText(awsProps.getProperty("aws.sdbdomain"));
            tf_SSH_User.setText(awsProps.getProperty("ssh.user"));
            str_AWS_Secret_Access_Key = awsProps.getProperty("aws.secretKey");

            if (awsProps.getProperty("aws.secretKey") != null) {
                lp_UserSettingsMsg.setRendered(true);
            } else {
                lp_UserSettingsMsg.setRendered(false);
            }

            if (awsProps.getProperty("aws.readamis") != null) {
                if (awsProps.getProperty("aws.readamis").equals("true")) {
                    cb_EC2ReadAMIs.setValue((Boolean) true);
                } else {
                    cb_EC2ReadAMIs.setValue((Boolean) false);
                }
            }
            getSessionBean1().setAWSProps(awsProps);
        }
    }

    public void ddl_AWSNickNames_processValueChange(ValueChangeEvent event) {
        String awsNickName = awsNickName = (String) ddl_AWSNickNames.getValue();
        getSessionBean1().setVisAWSNickNamesDDL(true);
        lp_EC2ConnectionMsg.setRendered(false);
        lp_SDBConnectionMsg.setRendered(false);
        setAWSxmlProps(awsNickName);
        AWS_Update_User_Settings_Form(getSessionBean1().getAWSProps());
    }

    public void AWS_CreateEC2Connection(Properties awsProps) {

        Map connectToRegions = new HashMap();
        ArrayList regionsList = null;
        String selectedItemsStr = ari_Regions.getSelectedValues();
        ProcessText processRegions = new ProcessText();

        try {
            regionsList = processRegions.processText(
                    selectedItemsStr, ari_Regions.getSeparator());
        } catch (Exception ex) {
            Logger.getLogger(EC2LaunchInstance.class.getName()).log(Level.SEVERE, null, ex);
        }

        if (regionsList != null) {
            for (int i = 0; i < regionsList.size(); i++) {
                connectToRegions.put(regionsList.get(i), regionsList.get(i));
            }
        } else {
            connectToRegions.put("us-east-1", "us-east-1");
        }

        HashMap ec2RegionsInfo = getSessionBean1().getEc2RegionDataProvider().getEC2RegionsMap();
        EC2Connection ec2Connection = new EC2Connection(awsProps, connectToRegions, ec2RegionsInfo);
        getSessionBean1().setEc2Connection(ec2Connection);
        checkEC2ConnectionStatusMsg();
    }

    public void AWS_CreateSDBConnection(Properties awsProps) {
        HashMap sdbServersInfo = getSessionBean1().getSdbServerDataProvider().getSDBServersMap();
        SDBConnection sdbconnection = new SDBConnection(awsProps, sdbServersInfo);
        getSessionBean1().setSdbConnection(sdbconnection);
        setSDBFunctionsVisibleTables();
    }
    public void AWS_CreateS3Connection(Properties awsProps) {
        HashMap s3ServersInfo = getSessionBean1().getS3StorageServerDataProvider().getS3ServersMap();
        S3StorageConnection s3StorageConnection = new S3StorageConnection(awsProps, s3ServersInfo);
        getSessionBean1().setS3StorageConnection(s3StorageConnection);
    }

    protected void setSDBFunctionsVisible(Boolean visible) {
        getSessionBean1().setVisinstInstname(visible);
        getSessionBean1().setVissnapSnapname(visible);
        getSessionBean1().setVisvolVolname(visible);
        getSessionBean1().setVisMetadataButton(visible);
    }

    protected void checkEC2ConnectionStatusMsg() {
        lp_EC2ConnectionMsg.setRendered(false);
        EC2Connection ec2Connection = null;
        if ((ec2Connection = getSessionBean1().getEc2Connection()) != null) {
            if (ec2Connection.getstatusmsg() != null) {
                String statusMsg = ec2Connection.getstatusmsg();
                setEc2conHtmlStatusMsg("EC2 connection: " + statusMsg);
                lp_EC2ConnectionMsg.setRendered(true);
                ec2Connection = null;
            }
        }
    }

    protected void setSDBFunctionsVisibleTables() {
        SDBConnection sdbconnection = null;
        lp_SDBConnectionMsg.setRendered(false);
        if ((sdbconnection = getSessionBean1().getSdbConnection()) != null) {
            if (sdbconnection.getstatusmsg() != null) {
                String statusMsg = sdbconnection.getstatusmsg();
                setSdbconHtmlStatusMsg(statusMsg);
                lp_SDBConnectionMsg.setRendered(true);
                setSDBFunctionsVisible(false);
            } else {
                setSDBFunctionsVisible(true);
            }
        } else {
            lp_SDBConnectionMsg.setRendered(false);
        }
    }
    //-------------------------------------------------------------------------
    protected String notesHtmlUserSettings = (String) getNotesHtmlUserSettings();

    /**
     * Get the value of notesUserSettings
     *
     * @return the value of notesUserSettings
     */
    public String getNotesHtmlUserSettings() {
        String strnotesUserSettings = new String();

        strnotesUserSettings = strnotesUserSettings + "<body>";
        strnotesUserSettings = strnotesUserSettings + "<ol style=\"font-family: Arial;font-size: 10pt;\">";
        strnotesUserSettings = strnotesUserSettings + "<li>User settings are never stored on disk on the server, not even temporarily. </li><br>";
        strnotesUserSettings = strnotesUserSettings + "<li>User settings can be loaded from a file on the client or entered manually.<br>";
        strnotesUserSettings = strnotesUserSettings + "The file format accepted is a text file (.txt) with the following entires:<br><br>";

        strnotesUserSettings = strnotesUserSettings + "<pre>";
        strnotesUserSettings = strnotesUserSettings + "aws.accessKey = your AWS access key<br>";
        strnotesUserSettings = strnotesUserSettings + "aws.secretKey = your AWS secret key<br>";
        strnotesUserSettings = strnotesUserSettings + "aws.accountId = your AWS account id<br>";
        strnotesUserSettings = strnotesUserSettings + "aws.sdbdomain = Simple DB domain for meta data<br>";
        strnotesUserSettings = strnotesUserSettings + "ssh.user      = login user id to use for ssh connection<br>";
        strnotesUserSettings = strnotesUserSettings + "</li>";
        strnotesUserSettings = strnotesUserSettings + "<li>Simple DB domain name must be set to enable Meta Data functionality.</li><br>";
        strnotesUserSettings = strnotesUserSettings + "<li>User must have a Simple DB account, otherwise meta data functionality is not enabled.</li><br>";
        strnotesUserSettings = strnotesUserSettings + "<li>If Simple DB is used, AWS Simple DB charges will be incurred as normal. Domain specificed by user is created if it does not already exist.</li><br>";

        strnotesUserSettings = strnotesUserSettings + "</ol></body>";

        return strnotesUserSettings;
    }

    /**
     * Set the value of notesUserSettings
     *
     * @param notesUserSettings new value of notesUserSettings
     */
    public void setNotesHtmlUserSettings(String notesHtmlUserSettings) {
        this.notesHtmlUserSettings = notesHtmlUserSettings;
    }
    //-------------------------------------------------------------------------
    protected String ec2conHtmlStatusMsg;

    /**
     * Get the value of ec2conHtmlStatusMsg
     *
     * @return the value of ec2conHtmlStatusMsg
     */
    public String getEc2conHtmlStatusMsg() {
        return ec2conHtmlStatusMsg;
    }

    /**
     * Set the value of ec2conHtmlStatusMsg
     *
     * @param ec2conHtmlStatusMsg new value of ec2conHtmlStatusMsg
     */
    public void setEc2conHtmlStatusMsg(String ec2conHtmlStatusMsg) {
        this.ec2conHtmlStatusMsg = ec2conHtmlStatusMsg;
    }
    //-------------------------------------------------------------------------
    protected String sdbconHtmlStatusMsg;

    /**
     * Get the value of sdbconHtmlStatusMsg
     *
     * @return the value of sdbconHtmlStatusMsg
     */
    public String getSdbconHtmlStatusMsg() {
        return sdbconHtmlStatusMsg;
    }

    /**
     * Set the value of sdbconHtmlStatusMsg
     *
     * @param sdbconHtmlStatusMsg new value of sdbconHtmlStatusMsg
     */
    public void setSdbconHtmlStatusMsg(String sdbconHtmlStatusMsg) {
        this.sdbconHtmlStatusMsg = sdbconHtmlStatusMsg;
    }
    //-------------------------------------------------------------------------

    public void setInitTab(String tabName) {
        if (getSessionBean1().getCurrentTabSet() == null) {
            tabSet_AWS_Main.setSelected(tabName);
            getSessionBean1().setCurrentTabSet(tabSet_AWS_Main);
        } else {
            tabSet_AWS_Main.setSelected(getSessionBean1().getCurrentTabSet().getSelected());
        }
    }

    //-------------------------------------------------------------------------
    public void saveTableStates() {
        Map tableStates = null;
        tableStates = getSessionBean1().getCurrentTableStates();
        if (tableStates == null) {
            tableStates = new HashMap();
        }
        tableStates.put("AWS_User_Settings", ac_User);
        tableStates.put("EC2_Images", table_EC2_Images);
        tableStates.put("EC2_Instances", table_EC2_Instances);
        tableStates.put("EBS_Volumes", table_EBS_Volumes);
        tableStates.put("EBS_Snapshots", table_EBS_Snapshots);
        tableStates.put("EC2_SecurityGroups", table_EC2_SecurityGroups);
        tableStates.put("EC2_Keypairs", table_EC2_Keypairs);
        tableStates.put("EC2_IPs", table_EC2_IPs);
        tableStates.put("SDB_Items", table_SDB_Items);
        tableStates.put("S3_Storage", table_S3Buckets);
        getSessionBean1().setCurrentTableStates(tableStates);
    }

    public void restoreTableStates() {
        Map tableStates = getSessionBean1().getCurrentTableStates();

        if (tableStates.get("AWS_User_Settings") != null) {
            ac_User = (Accordion) tableStates.get("AWS_User_Settings");
        }
        if (tableStates.get("EC2_Images") != null) {
            table_EC2_Images = (Table) tableStates.get("EC2_Images");
        }
        if (tableStates.get("EC2_Instances") != null) {
            table_EC2_Instances = (Table) tableStates.get("EC2_Instances");
        }
        if (tableStates.get("EBS_Volumes") != null) {
            table_EBS_Volumes = (Table) tableStates.get("EBS_Volumes");
        }
        if (tableStates.get("EBS_Snapshots") != null) {
            table_EBS_Snapshots = (Table) tableStates.get("EBS_Snapshots");
        }
        if (tableStates.get("EC2_SecurityGroups") != null) {
            table_EC2_SecurityGroups = (Table) tableStates.get("EC2_SecurityGroups");
        }
        if (tableStates.get("EC2_Keypairs") != null) {
            table_EC2_Keypairs = (Table) tableStates.get("EC2_Keypairs");
        }
        if (tableStates.get("EC2_IPs") != null) {
            table_EC2_IPs = (Table) tableStates.get("EC2_IPs");
        }
        if (tableStates.get("SDB_Items") != null) {
            table_SDB_Items = (Table) tableStates.get("SDB_Items");
        }
        if (tableStates.get("S3_Storage") != null) {
            table_S3Buckets = (Table) tableStates.get("S3_Storage");
        }
    }
    //-------------------------------------------------------------------------

    public String getStateStyleClass() {
        String state = (String) getValue("#{currentRow.value['stateName']}");
        if ((state != null) && (state.startsWith("running") || state.startsWith("in-use") || state.startsWith("attached"))) {
            return "stateRunningStyleClass";
        } else if (((state != null) && (state.startsWith("pending")))) {
            return "statePendingStyleClass";
        } else if (((state != null) && (state.startsWith("available")))) {
            return "stateAvailableStyleClass";
        } else if (((state != null) && (state.startsWith("creating")))) {
            return "statePendingStyleClass";
        } else if (((state != null) && (state.startsWith("shutting-down") || state.startsWith("deleting")))) {
            return "stateShuttingDownStyleClass";
        } else if (((state != null) && (state.startsWith("terminated")))) {
            return "stateTerminatedStyleClass";
        } else {
            return "noStyleClass";
        }
    }

    public String getItemStateStyleClass() {
        String state = (String) getValue("#{currentRow.value['state']}");
        if ((state != null) && (state.startsWith("running") || state.startsWith("in-use") || state.startsWith("attached"))) {
            return "stateRunningStyleClass";
        } else if ((state != null) && (state.startsWith("completed"))) {
            return "stateRunningStyleClass";
        } else if (((state != null) && (state.startsWith("pending")))) {
            return "statePendingStyleClass";
        } else if (((state != null) && (state.startsWith("available")))) {
            return "stateAvailableStyleClass";
        } else if (((state != null) && (state.startsWith("creating")))) {
            return "statePendingStyleClass";
        } else if (((state != null) && (state.startsWith("shutting-down") || state.startsWith("deleting")))) {
            return "stateShuttingDownStyleClass";
        } else if (((state != null) && (state.startsWith("terminated")))) {
            return "stateTerminatedStyleClass";
        } else {
            return "noStyleClass";
        }
    }

    public String getVolStatusStyleClass() {
        String state = (String) getValue("#{currentRow.value['vstatus']}");
        if ((state != null) && (state.startsWith("in-use"))) {
            return "stateRunningStyleClass";
        } else if (((state != null) && (state.startsWith("available")))) {
            return "stateAvailableStyleClass";
        } else if (((state != null) && (state.startsWith("creating")))) {
            return "statePendingStyleClass";
        } else if (((state != null) && (state.startsWith("shutting-down") || state.startsWith("deleting")))) {
            return "stateShuttingDownStyleClass";
        } else if (((state != null) && (state.startsWith("terminated")))) {
            return "stateTerminatedStyleClass";
        } else {
            return "noStyleClass";
        }
    }

    public String getVolAttachedStyleClass() {
        String state = (String) getValue("#{currentRow.value['astatus']}");
        if ((state != null) && (state.startsWith("in-use") || state.startsWith("attached"))) {
            return "stateRunningStyleClass";
        } else if (((state != null) && (state.startsWith("detaching")))) {
            return "statePendingStyleClass";
        } else if (((state != null) && (state.startsWith("attaching")))) {
            return "statePendingStyleClass";
        } else if (((state != null) && (state.startsWith("busy")))) {
            return "stateTerminatedStyleClass";
        } else {
            return "noStyleClass";
        }
    }

    public String getSnapStatusStyleClass() {
        String state = (String) getValue("#{currentRow.value['status']}");
        if ((state != null) && (state.startsWith("completed"))) {
            return "stateRunningStyleClass";
        } else if (((state != null) && (state.startsWith("available")))) {
            return "stateAvailableStyleClass";
        } else if (((state != null) && (state.startsWith("shutting-down") || state.startsWith("deleting")))) {
            return "stateShuttingDownStyleClass";
        } else if (((state != null) && (state.startsWith("terminated")))) {
            return "stateTerminatedStyleClass";
        } else if (((state != null) && (state.startsWith("pending")))) {
            return "statePendingStyleClass";
        } else {
            return "noStyleClass";
        }
    }

    public String btn_S3Cockpit_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        return null;
    }

    public String btn_UploadS3Bucket_action() {
        // TODO: Replace with your code
        return null;
    }

    public void tf_AWS_Access_Key_processValueChange(ValueChangeEvent event) {
    }
}
